Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String length validation for encrypted filed? #186

Closed
shrkw opened this issue Oct 2, 2020 · 3 comments
Closed

String length validation for encrypted filed? #186

shrkw opened this issue Oct 2, 2020 · 3 comments

Comments

@shrkw
Copy link

shrkw commented Oct 2, 2020

Hi,

I want to validate length for encrypted filed.
But standard way counts as byte length. So it does not work for string length.

validates :name, length: { maximum: 20 }

Do you have any idea for that?

@shrkw
Copy link
Author

shrkw commented Oct 2, 2020

Sorry, this is due to multi byte encoding.
I can validate by name.force_encoding('utf-8').length.

Sorry to bother you.

@shrkw shrkw closed this as completed Oct 2, 2020
@jmazzi
Copy link
Owner

jmazzi commented Oct 2, 2020 via email

@shrkw
Copy link
Author

shrkw commented Oct 5, 2020

I think it is common use case though, I don't want to accept too long name input to users.
I added client side length validation, and I wanted to add it on rails side too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants