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

Validator proposal: same_as #1846

Closed
glaucocustodio opened this issue Dec 14, 2018 · 4 comments
Closed

Validator proposal: same_as #1846

glaucocustodio opened this issue Dec 14, 2018 · 4 comments

Comments

@glaucocustodio
Copy link
Contributor

Hi folks, I just added a custom validator (same_as) to my app and I would like to know whether it would be welcome to grape itself:

resources :passwords do
  params do
    requires :current_password, allow_blank: false
    requires :password, allow_blank: false
    requires :password_confirmation, allow_blank: false, same_as: :password
  end
  post do
  end
end

Thanks.

@myxoh
Copy link
Member

myxoh commented Dec 14, 2018

Can you think of any other example in which it would be useful other that the password password_confirmation?
I've spent some time trying to think of alternative use cases and I'm having a hard time. If there aren't any it seems to be as a bit of an overkill to have a validator for just one use case, especially as there are plenty of libraries that handle this specific validation at the model level (arguably it'd be better at a param level, but seems to niche)

I'll let @dblock make the final call

@glaucocustodio
Copy link
Contributor Author

I can only think in confirmation cases like email and password. Anyway I would say it is worth to have common validators built-in like this one and some others like length. Those are very small, isolated (one file) and nice to have.

@dblock
Copy link
Member

dblock commented Dec 16, 2018

I like it. Would merge a PR.

@glaucocustodio
Copy link
Contributor Author

I am closing because it was implemented on PR #1850.

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

No branches or pull requests

3 participants