mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
parent
0f352cab24
commit
d520b5b157
50 changed files with 2462 additions and 323 deletions
12
lib/validators/e164_validator.rb
Normal file
12
lib/validators/e164_validator.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class E164Validator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, _value)
|
||||
length_validator = ActiveModel::Validations::
|
||||
LengthValidator.new(maximum: 17, attributes: attribute)
|
||||
length_validator.validate(record)
|
||||
|
||||
format_validator = ActiveModel::Validations::
|
||||
FormatValidator.new(with: /\+[0-9]{1,3}\.[0-9]{1,14}?/,
|
||||
attributes: attribute)
|
||||
format_validator.validate(record)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue