Class: Stockade::Lexemes::PaymentCard
- Defined in:
- lib/stockade/lexemes/payment_card.rb
Overview
Lexeme for anything that resembles payment card numbers en.wikipedia.org/wiki/Payment_card_number
Any 10-19 character long sequences of digits optionally grouped using ‘ ’ or ‘-’ delimiters are suspects
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#==, #end_pos, #initialize, #mask, #range, #token, #type, types, #value
Constructor Details
This class inherits a constructor from Stockade::Lexemes::Base
Class Method Details
.regex ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/stockade/lexemes/payment_card.rb', line 13 def self.regex / (?<!\d) # NaN \d ([\s\-]*\d[\s\-]*){10,17} \d (?!\d) # NaN /x end |
Instance Method Details
#valid? ⇒ Boolean
23 24 25 |
# File 'lib/stockade/lexemes/payment_card.rb', line 23 def valid? CreditCardValidations::Detector.new(value).valid? end |