v-credit-card ( str -- n )
Form validators

Prev:v-password ( str -- str )
Next:v-mode ( str -- str )


Vocabulary
validators

Inputs
stra string


Outputs
nan integer


Word description
If the credit card number passes the Luhn algorithm, converts it to an integer, otherwise throws an error.

Notes
See http://en.wikipedia.org/wiki/Luhn_algorithm for a description of this algorithm.

Definition


: v-credit-card ( str -- n )
"- " without dup 48 57 [a..b] diff empty? [
13 v-min-length 16 v-max-length dup luhn?
[ string>number ] [ "card number check failed" throw ]
if
] [ "invalid credit card number format" throw ] if ;