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

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

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

CATEGORY

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