mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
parent
7d2d34cb34
commit
bc3962cdfa
4 changed files with 63 additions and 16 deletions
10
lib/validators/e164_validator.rb
Normal file
10
lib/validators/e164_validator.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue