Sha256: 91efaa77877f03aeaf65aecbc74ad0cc91723bcbef2a39ff2b83b58e192fc70a
Contents?: true
Size: 473 Bytes
Versions: 17
Compression:
Stored size: 473 Bytes
Contents
class TrackingNumberValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return unless value.present? if options[:exception] == value || options[:except] == value # magic valid value (an exception that says "not really shipped" or something) elsif TrackingNumber.new(value).valid? # looks good to me else record.errors.add(attribute, options[:message] || 'is not a valid tracking number') end end end
Version data entries
17 entries across 17 versions & 1 rubygems