logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

valtype::creditcard::visa - Validation for VISA creditcard number

Api

       The API provided by this package satisfies the specification  of  snit  validation  types  found  in  the
       documentation of Snit'sNotIncrTcl.

       valtype::creditcard::visavalidatevalue
              This method validates the value and returns it, possibly in a canonical form, if it passes. If the
              value does not pass the validation an error is thrown.

       valtype::creditcard::visacheckdigitvalue
              This  method  computes  a check digit for the value. Before doing so it is validated, except for a
              checkdigit. If the value does not pass the validation no check digit is calculated and an error is
              thrown instead.

Bugs, Ideas, Feedback

       This document, and the package it describes, will undoubtedly contain bugs and  other  problems.   Please
       report  such  in  the  category  valtype  of  the TcllibTrackers [http://core.tcl.tk/tcllib/reportlist].
       Please also report any ideas for enhancements you may have for either package and/or documentation.

       When proposing code changes, please provide unifieddiffs, i.e the output of diff-u.

       Note further that attachments are strongly preferred over inlined patches. Attachments  can  be  made  by
       going  to the Edit form of the ticket immediately after its creation, and then using the left-most button
       in the secondary navigation bar.

Category

       Validation, Type checking

Description

       This package implements a snit validation type for a VISA creditcard number.

       A  validation  type  is  an  object  that  can  be used to validate Tcl values of a particular kind.  For
       example, snit::integer, a validation type defined by the snit package is used  to  validate  that  a  Tcl
       value is an integer.

       Every  validation  type has a validate method which is used to do the validation. This method must take a
       single argument, the value to be validated; further, it must do nothing if the value is valid, but  throw
       an error if the value is invalid:

                  valtype::creditcard::visa validate .... ;# Does nothing
                  valtype::creditcard::visa validate .... ;# Throws an error (bad VISA creditcard number).

       The  validate  method will always return the validated value on success, and throw the -errorcode INVALID
       on error, possibly with additional elements which provide more details about the problem.

Error Codes

       As said in the package description, the errors thrown by the commands of  this  package  in  response  to
       input  validation  failures  use  the  -errorcode INVALID to distinguish themselves from package internal
       errors.

       To provide more detailed information about why the validation failed the -errorCode goes actually  beyond
       that.   First,  it  will  contain a code detailing the type itself. Here this is CREDITCARDVISA. This is
       then followed by values detailing the reason for the failure. The full set of -errorCodes  which  can  be
       thrown by this package are:

       INVALID CREDITCARD VISA CHARACTER
              The  input value contained one or more bad characters, i.e. characters which must not occur in the
              input for it to be a VISA creditcard number.

       INVALID CREDITCARD VISA CHECK-DIGIT
              The check digit of the input value is wrong. This usually signals a data-entry error, with  digits
              transposed, forgotten, etc. Of course, th input may be an outright fake too.

       INVALID CREDITCARD VISA LENGTH
              The input value is of the wrong length to be a VISA creditcard number.

       INVALID CREDITCARD VISA PREFIX
              The  input  value  does  not start with the magic value(s) required for it to be a VISA creditcard
              number.

Keywords

       Checking, Testing, Type checking, VISA, Validation, Value checking, bank, card for credit,  credit  card,
       finance, isA

Name

       valtype::creditcard::visa - Validation for VISA creditcard number

Synopsis

       package require Tcl8.59

       package require snit2

       package require valtype::common

       package require valtype::luhn

       package require valtype::creditcard::visa?1.1?valtype::creditcard::visavalidatevaluevaltype::creditcard::visacheckdigitvalue

________________________________________________________________________________________________________________

See Also