Sha256: 184b58be48cd2791680b76d7c21d197d7094d75920e2b1688367e436e455852a
Contents?: true
Size: 393 Bytes
Versions: 3
Compression:
Stored size: 393 Bytes
Contents
class CreditCardNumberValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) brands = options.fetch(:brands) record.errors[attribute] << (options[:message] || "is not valid") unless credit_card_valid?(value, Array.wrap(brands)) end def credit_card_valid?(number, brands = []) CreditCardValidations::Detector.new(number).valid?(*brands) end end
Version data entries
3 entries across 3 versions & 1 rubygems