Method: ActiveModel::Validations::PostcodeValidator#validate_each
- Defined in:
- lib/active_model/validations/postcode_validator.rb
#validate_each(record, attribute, value) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/active_model/validations/postcode_validator.rb', line 8 def validate_each(record, attribute, value) country = option_call(record, :country) record.errors.add(attribute, :invalid_postcode) unless validator.valid?(value, country: country) rescue ::PostcodeValidator::Error # When :country is not a valid country, just skip postcode validation # :country validation is developer's responsability end |