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