class WireClient::CountrySubdivisionValidator

Public Instance Methods

validate(record) click to toggle source
# File lib/wire_client/base/validators.rb, line 50
def validate(record)
  field_name, value = extract_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