class Apes::Validators::PhoneValidator

Validates phones.

Constants

VALID_REGEX

The pattern to recognize valid phones.

Public Class Methods

new(options) click to toggle source

Creates a new validator.

@param options [Hash] The options for the validations. @return [Apes::Validators::PhoneValidator] A new validator.

Calls superclass method
# File lib/apes/validators.rb, line 145
def initialize(options)
  super(options.reverse_merge(default_message: "must be a valid phone"))
end

Public Instance Methods

check_valid?(value) click to toggle source

Checks if the value is valid for this validator.

@param value [Object] The value to validate. @return [Boolean] `true` if the value is valid, false otherwise.

# File lib/apes/validators.rb, line 153
def check_valid?(value)
  value.blank? || value =~ VALID_REGEX
end