1valtype::creditcard::discover(n)Validation typesvaltype::creditcard::discover(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       valtype::creditcard::discover - Validation for Discover creditcard num‐
9       ber
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::discover  ?1?
21
22       valtype::creditcard::discover validate value
23
24       valtype::creditcard::discover checkdigit value
25
26______________________________________________________________________________
27

DESCRIPTION

29       This package implements a snit validation type for a  Discover  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::discover validate .... ;# Does nothing
44                  valtype::creditcard::discover validate .... ;# Throws an error (bad Discover 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::discover 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::discover 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 DISCOVER.  This
75       is  then  followed  by values detailing the reason for the failure. The
76       full set of -errorCodes which can be thrown by this package are:
77
78       INVALID CREDITCARD DISCOVER 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 Discover
81              creditcard number.
82
83       INVALID CREDITCARD DISCOVER 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 DISCOVER LENGTH
89              The input value is of the wrong length to be a Discover  credit‐
90              card number.
91
92       INVALID CREDITCARD DISCOVER PREFIX
93              The  input value does not start with the magic value(s) required
94              for it to be a Discover 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, Discover, Testing, Type checking, Validation, Value checking,
113       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::discover(n)
Impressum