Class: PostcodeValidator
- Inherits:
-
Object
- Object
- PostcodeValidator
- Defined in:
- lib/postcode_validator.rb,
lib/postcode_validator/version.rb
Overview
A simple postcode validator
Can be used to validate a post code, regarding a country specified through the :country option as an ISO-3166-2 code.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
'1.0.2'
Instance Method Summary collapse
Instance Method Details
#valid?(postcode, options = {}) ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/postcode_validator.rb', line 25 def valid?(postcode, = {}) iso = country_as_iso() postcode = postcode.to_s.strip validator = validator_for(iso) validator ? validator.valid?(postcode) : postcode.blank? end |