mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
10 lines
449 B
Ruby
10 lines
449 B
Ruby
class E164Validator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
validator = ActiveModel::Validations::LengthValidator.new(maximum: 17, attributes: attribute)
|
|
validator.validate(record)
|
|
|
|
validator = ActiveModel::Validations::FormatValidator.new(with: /\+[0-9]{1,3}\.[0-9]{1,14}?/,
|
|
attributes: attribute)
|
|
validator.validate(record)
|
|
end
|
|
end
|