1valtype::creditcard::visa(n)   Validation types   valtype::creditcard::visa(n)
2
3
4
5______________________________________________________________________________
6

NAME

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

SYNOPSIS

11       package require Tcl  8.5
12
13       package require snit  2
14
15       package require valtype::common
16
17       package require valtype::luhn
18
19       package require valtype::creditcard::visa  ?1?
20
21       valtype::creditcard::visa validate value
22
23       valtype::creditcard::visa checkdigit value
24
25______________________________________________________________________________
26

DESCRIPTION

28       This  package  implements  a snit validation type for a VISA creditcard
29       number.
30
31       A validation type is an object that can be used to validate Tcl  values
32       of  a  particular  kind.  For example, snit::integer, a validation type
33       defined by the snit package is used to validate that a Tcl value is  an
34       integer.
35
36       Every  validation  type  has  a validate method which is used to do the
37       validation. This method must take a single argument, the  value  to  be
38       validated; further, it must do nothing if the value is valid, but throw
39       an error if the value is invalid:
40
41
42                  valtype::creditcard::visa validate .... ;# Does nothing
43                  valtype::creditcard::visa validate .... ;# Throws an error (bad VISA creditcard number).
44
45
46       The validate method will always return the validated value on  success,
47       and throw the -errorcode INVALID on error, possibly with additional el‐
48       ements which provide more details about the problem.
49

API

51       The API provided by this package satisfies the  specification  of  snit
52       validation types found in the documentation of Snit's Not Incr Tcl.
53
54       valtype::creditcard::visa validate value
55              This  method  validates  the value and returns it, possibly in a
56              canonical form, if it passes. If the value  does  not  pass  the
57              validation an error is thrown.
58
59       valtype::creditcard::visa checkdigit value
60              This  method  computes a check digit for the value. Before doing
61              so it is validated, except for a checkdigit. If the  value  does
62              not  pass the validation no check digit is calculated and an er‐
63              ror is thrown instead.
64

ERROR CODES

66       As said in the package description, the errors thrown by  the  commands
67       of  this  package in response to input validation failures use the -er‐
68       rorcode INVALID to distinguish themselves from package internal errors.
69
70       To provide more detailed information about why  the  validation  failed
71       the  -errorCode  goes  actually  beyond that.  First, it will contain a
72       code detailing the type itself. Here this is CREDITCARD VISA.  This  is
73       then  followed by values detailing the reason for the failure. The full
74       set of -errorCodes which can be thrown by this package are:
75
76       INVALID CREDITCARD VISA CHARACTER
77              The input value contained one or more bad characters, i.e. char‐
78              acters  which  must  not  occur in the input for it to be a VISA
79              creditcard number.
80
81       INVALID CREDITCARD VISA CHECK-DIGIT
82              The check digit of the input value is wrong. This  usually  sig‐
83              nals a data-entry error, with digits transposed, forgotten, etc.
84              Of course, th input may be an outright fake too.
85
86       INVALID CREDITCARD VISA LENGTH
87              The input value is of the wrong length to be a  VISA  creditcard
88              number.
89
90       INVALID CREDITCARD VISA PREFIX
91              The  input value does not start with the magic value(s) required
92              for it to be a VISA creditcard number.
93

BUGS, IDEAS, FEEDBACK

95       This document, and the package it describes, will  undoubtedly  contain
96       bugs and other problems.  Please report such in the category valtype of
97       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
98       also  report any ideas for enhancements you may have for either package
99       and/or documentation.
100
101       When proposing code changes, please provide unified diffs, i.e the out‐
102       put of diff -u.
103
104       Note  further  that  attachments  are  strongly  preferred over inlined
105       patches. Attachments can be made by going  to  the  Edit  form  of  the
106       ticket  immediately  after  its  creation, and then using the left-most
107       button in the secondary navigation bar.
108

KEYWORDS

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

CATEGORY

114       Validation, Type checking
115
117       Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
118
119
120
121
122tcllib                                 1          valtype::creditcard::visa(n)
Impressum