Class: Owasp::Esapi::Validator::Zipcode
- Inherits:
-
GenericValidator
- Object
- GenericValidator
- Owasp::Esapi::Validator::Zipcode
- Defined in:
- lib/validator/zipcode.rb
Overview
This is a validator class for zip codes.
Constant Summary collapse
- ITALIAN_ZIPCODE =
"^\\d{5}$"
- US_ZIPCODE =
"^\\d{5}(\\-\\d{4})?$"
Instance Attribute Summary
Attributes inherited from GenericValidator
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Zipcode
constructor
Creates a new Zipcode validator.
Methods inherited from GenericValidator
Constructor Details
#initialize(options = nil) ⇒ Zipcode
Creates a new Zipcode validator. very custom one
16 17 18 19 20 21 22 |
# File 'lib/validator/zipcode.rb', line 16 def initialize( = nil) # Matcher is tuned to match a valid US ZIP CODE, that means either 5 numbers, or 5 numbers, # plus a dash, then 4 more numbers. @matcher = US_ZIPCODE @matcher = ["custom_regex"] unless (.nil? || ! .has_key?("custom_regex")) super(@matcher) end |