internetee-registry/lib/validators/iso31661_alpha2_validator.rb
2017-08-18 13:02:54 +03:00

11 lines
296 B
Ruby

class Iso31661Alpha2Validator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid_iso31661_alpha2) unless valid_country_code?(value)
end
private
def valid_country_code?(country_code)
Country.new(country_code)
end
end