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

NAME

8       valtype::common - Validation, common code
9

SYNOPSIS

11       package require Tcl  8.5
12
13       package require valtype::common  ?1?
14
15       valtype::common::reject code text
16
17       valtype::common::badchar code ?text?
18
19       valtype::common::badcheck code ?text?
20
21       valtype::common::badlength code lengths ?text?
22
23       valtype::common::badprefix code prefixes ?text?
24
25______________________________________________________________________________
26

DESCRIPTION

28       This package implements a number of common commands used by the valida‐
29       tion types in this module. These commands essentially  encapsulate  the
30       throwing  of  validation  errors,  ensuring that a proper -errorcode is
31       used. See section Error Codes.
32

API

34       valtype::common::reject code text
35              The core command of this package it throws an INVALID error with
36              the  specified  text.  The  first  argument  is  a list of codes
37              extending the INVALID with detail information.
38
39       valtype::common::badchar code ?text?
40              This command throws an INVALID CHAR  error  with  the  specified
41              text.  The  first argument is a list of codes providing details.
42              These are inserted between the codes INVALID and CHARACTER.
43
44       valtype::common::badcheck code ?text?
45              This command throws an INVALID CHECK-DIGIT error with the speci‐
46              fied  text,  if  any,  extended  by the standard text "the check
47              digit is incorrect". The first argument is a list of codes  pro‐
48              viding details. These are inserted between the codes INVALID and
49              CHECK_DIGIT.
50
51       valtype::common::badlength code lengths ?text?
52              This command throws an INVALID LENGTH error with  the  specified
53              text,  if  any, extended by the standard text "incorrect length,
54              expected ... character(s)". The first  argument  is  a  list  of
55              codes  providing  details.  These are inserted between the codes
56              INVALID and LENGTH. The argument lengths is a list of the  input
57              lengths  which  had  been  expected,  i.e.  these  are the valid
58              lengths.
59
60       valtype::common::badprefix code prefixes ?text?
61              This command throws an INVALID PREFIX error with  the  specified
62              text,  if  any, extended by the standard text "incorrect prefix,
63              expected ...". The first argument is a list of  codes  providing
64              details.   These are inserted between the codes INVALID and PRE‐
65              FIX. The argument prefixes is a list of the input prefixes which
66              had been expected, i.e. these are the valid prefixes.
67

ERROR CODES

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

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

113       Checking, Testing, Type checking, Validation, Value checking, 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::common(n)
Impressum