1valtype::creditcard::mastercard(Vna)lidation typveasltype::creditcard::mastercard(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       valtype::creditcard::mastercard  - Validation for Mastercard creditcard
9       number
10

SYNOPSIS

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

DESCRIPTION

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

API

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

ERROR CODES

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

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

111       Checking,  MasterCard, Testing, Type checking, Validation, Value check‐
112       ing, bank, card for credit, credit card, finance, isA
113

CATEGORY

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