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

NAME

8       valtype::verhoeff  - Validation for plain number with a VERHOEFF check‐
9       digit
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::verhoeff  ?1?
19
20       valtype::verhoeff validate value
21
22       valtype::verhoeff checkdigit value
23
24______________________________________________________________________________
25

DESCRIPTION

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

API

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

ERROR CODES

65       As  said  in the package description, the errors thrown by the commands
66       of this package in  response  to  input  validation  failures  use  the
67       -errorcode  INVALID  to  distinguish  themselves  from package internal
68       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  VERHOEFF.  This  is  then
73       followed  by  values detailing the reason for the failure. The full set
74       of -errorCodes which can be thrown by this package are:
75
76       INVALID VERHOEFF 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 plain
79              number with a VERHOEFF checkdigit.
80
81       INVALID VERHOEFF 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

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

102       Checking, Testing, Type checking, Validation, Value checking, isA, ver‐
103       hoeff
104

CATEGORY

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