Sha256: cca5e8d5ca3b4b2d44a5a4beab71ae855790d92dadc0721dc6368ae7c4963b0a
Contents?: true
Size: 388 Bytes
Versions: 3
Compression:
Stored size: 388 Bytes
Contents
class PostalCodeFormatValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) unless value =~ /\A(\d{5}((-|\s)\d{4})?)|([txTX]\d[abceghjklmnprtvxyzABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[abceghjklmnprstvxyzABCEGHJKLMNPRSTVWXYZ]\d)\z/ object.errors[attribute] << (options[:message] || "enter a valid AB or NT postal code (e.g. T2T 2T2)") end end end
Version data entries
3 entries across 3 versions & 1 rubygems