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

Can i skip a validation with another number? #110

Closed
fabiancarlos opened this issue Aug 13, 2015 · 2 comments
Closed

Can i skip a validation with another number? #110

fabiancarlos opened this issue Aug 13, 2015 · 2 comments

Comments

@fabiancarlos
Copy link

I want to skip the validation if number is like, '0800', a common number here in Brazil. How is the way to do it?

@mhink
Copy link

mhink commented Aug 18, 2015

So, Rails will let you do conditional validations based on the return value of a Proc.

http://guides.rubyonrails.org/v3.2.13/active_record_validations_callbacks.html#using-a-proc-with-if-and-unless

This library looks like it follows Rails 4 conventions well, so you should be able to do something like this:

validate :phone_number, :phony_plausible => true, :unless => Proc.new { |your_model| your_model.should_skip_validation? }

@joost
Copy link
Owner

joost commented Aug 19, 2015

Yep. @mhink 's solution is the way to go.

@joost joost closed this as completed Aug 19, 2015
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

3 participants