Sha256: 6779b40adb8c29f77d3da616e089542fb3d99cd7389c051625312913fe0477c0
Contents?: true
Size: 350 Bytes
Versions: 13
Compression:
Stored size: 350 Bytes
Contents
class CreditCardFormatValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) unless value =~ /((4\d{3})|(5[1-5]\d{2})|(6011)|(34\d{1})|(37\d{1}))-?\d{4}-?\d{4}-?\d{4}|3[4,7][\d\s-]{15}/ object.errors[attribute] << (options[:message] || "enter a valid credit card number (Visa or Mastercard)") end end end
Version data entries
13 entries across 13 versions & 1 rubygems