class Apes::Validators::ZipCodeValidator
Validates ZIP codes.
Constants
- VALID_REGEX
The pattern to recognized valid ZIP codes.
Public Class Methods
new(options)
click to toggle source
Creates a new validator.
@param options [Hash] The options for the validations. @return [Apes::Validators::ZipCodeValidator] A new validator.
Calls superclass method
# File lib/apes/validators.rb, line 167 def initialize(options) super(options.reverse_merge(default_message: "must be a valid ZIP code")) 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 175 def check_valid?(value) value.blank? || value =~ VALID_REGEX end