Class: Apes::Validators::PhoneValidator
- Inherits:
-
BaseValidator
- Object
- ActiveModel::EachValidator
- BaseValidator
- Apes::Validators::PhoneValidator
- Defined in:
- lib/apes/validators.rb
Overview
Validates phones.
Constant Summary
- VALID_REGEX =
The pattern to recognize valid phones.
/^( ((\+|00)\d)? # International prefix ([0-9\-\s\/\(\)]{7,}) # All the rest )$/mx
Instance Method Summary (collapse)
-
- (Boolean) check_valid?(value)
Checks if the value is valid for this validator.
-
- (Apes::Validators::PhoneValidator) initialize(options)
constructor
Creates a new validator.
Methods inherited from BaseValidator
Constructor Details
- (Apes::Validators::PhoneValidator) initialize(options)
Creates a new validator.
145 146 147 |
# File 'lib/apes/validators.rb', line 145 def initialize() super(.reverse_merge(default_message: "must be a valid phone")) end |
Instance Method Details
- (Boolean) check_valid?(value)
Checks if the value is valid for this validator.
153 154 155 |
# File 'lib/apes/validators.rb', line 153 def check_valid?(value) value.blank? || value =~ VALID_REGEX end |