module Europe::Postal
VAT
Constants
- POSTAL_REGEX
rubocop:disable Layout/LineLength
Public Class Methods
match_postal_code(postal_code, country_code)
click to toggle source
# File lib/europe/postal/postal.rb, line 46 def self.match_postal_code(postal_code, country_code) if POSTAL_REGEX[country_code.to_sym].is_a?(Array) POSTAL_REGEX[country_code.to_sym].each do |regex| return true if regex.match(postal_code) end elsif POSTAL_REGEX[country_code.to_sym].match(postal_code) return true end false end
validate(country_code, postal_code)
click to toggle source
rubocop:enable Layout/LineLength
# File lib/europe/postal/postal.rb, line 40 def self.validate(country_code, postal_code) return false unless POSTAL_REGEX.key?(country_code.to_sym) match_postal_code(postal_code, country_code) end