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

NAME

8       valtype::luhn5 - Validation for plain number with a LUHN5 checkdigit
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::luhn5  ?1?
18
19       valtype::luhn5 validate value
20
21       valtype::luhn5 checkdigit value
22
23______________________________________________________________________________
24

DESCRIPTION

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

API

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

ERROR CODES

64       As said in the package description, the errors thrown by  the  commands
65       of  this  package  in  response  to  input  validation failures use the
66       -errorcode INVALID to  distinguish  themselves  from  package  internal
67       errors.
68
69       To  provide  more  detailed information about why the validation failed
70       the -errorCode goes actually beyond that.  First,  it  will  contain  a
71       code  detailing  the type itself. Here this is LUHN5. This is then fol‐
72       lowed by values detailing the reason for the failure. The full  set  of
73       -errorCodes which can be thrown by this package are:
74
75       INVALID LUHN5 CHARACTER
76              The input value contained one or more bad characters, i.e. char‐
77              acters which must not occur in the input for it to  be  a  plain
78              number with a LUHN5 checkdigit.
79
80       INVALID LUHN5 CHECK-DIGIT
81              The  check  digit of the input value is wrong. This usually sig‐
82              nals a data-entry error, with digits transposed, forgotten, etc.
83              Of course, th input may be an outright fake too.
84

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

101       Checking,  Testing,  Type  checking,  Validation,  Value checking, isA,
102       luhn, luhn-5
103

CATEGORY

105       Validation, Type checking
106
108       Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
109
110
111
112
113tcllib                                 1                     valtype::luhn5(n)
Impressum