I want to create some validations for one of my models which contain location information(street, locality, postal_code, etc). I want to be able to change the validation rules based on which country is selected.
For example, the validation rules for postal_code will be different for the US & Canada. Furthermore, some countries don’t have postal_codes so no validation rules would be needed.
How would I go about implementing something like this?
Put this in your model to run any custom logic for validation.
Read more about this in the Rails Guides:
http://guides.rubyonrails.org/active_record_validations_callbacks.html#creating-custom-validation-methods