Class: WireClient::CountrySubdivisionValidator
Instance Method Summary
collapse
#extract_field_name_value
Instance Method Details
#validate(record) ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/wire_client/base/validators.rb', line 50
def validate(record)
field_name, value = (record)
country = record.send(options[:country] || :country).to_s
if country == 'US'
unless US_STATES.key?(value) || US_STATES.value?(value)
record.errors.add(field_name, :invalid, message: options[:message])
end
end
end
|