Class: PostcodeFormatValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PostcodeFormatValidator
- Defined in:
- lib/postoffice.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(object, attribute, value) ⇒ Object
181 182 183 184 185 186 187 188 |
# File 'lib/postoffice.rb', line 181 def validate_each(object, attribute, value) result = PostOffice.validate_postcode(value, [:country_code]) if !result object.errors[attribute] << ([:message] || "entered is not a valid postcode for #{PostOffice.country_name(options[:country_code])}.") end end |