internetee-registry/lib/validators/iso31661_alpha2_validator.rb
Artur Beljajev d520b5b157 Revert "Revert "Registry 569""
This reverts commit 4786dbb
2017-10-22 23:57:11 +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