mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
11 lines
296 B
Ruby
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
|