File: valtype_common.man

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (110 lines) | stat: -rw-r--r-- 4,344 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
[comment {-*- tcl -*- --- doctools ---}]
[manpage_begin valtype::common n 1.1]
[keywords Checking]
[keywords isA]
[keywords Testing]
[keywords {Type checking}]
[keywords Validation]
[keywords {Value checking}]
[copyright {2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>}]
[titledesc "Validation, common code"]
[moddesc {Validation types}]
[category {Validation, Type checking}]
[require Tcl "8.5 9"]
[require valtype::common [opt 1.1]]
[description]

This package implements a number of common commands used by the
validation types in this module. These commands essentially
encapsulate the throwing of validation errors, ensuring that a proper
[cmd -errorcode] is used. See section [sectref {Error Codes}].

[section API]

[list_begin definitions]
[comment {==================================================================}]
[call [cmd valtype::common::reject] [arg code] [arg text]]

The core command of this package it throws an [const INVALID] error
with the specified [arg text]. The first argument is a list of codes
extending the [const INVALID] with detail information.

[comment {==================================================================}]
[call [cmd valtype::common::badchar] [arg code] [opt [arg text]]]

This command throws an [const {INVALID CHAR}] error with the specified
[arg text]. The first argument is a list of codes providing
details. These are inserted between the codes [const INVALID] and
[const CHARACTER].

[comment {==================================================================}]
[call [cmd valtype::common::badcheck] [arg code] [opt [arg text]]]

This command throws an [const {INVALID CHECK-DIGIT}] error with the
specified [arg text], if any, extended by the standard text "the check
digit is incorrect". The first argument is a list of codes providing
details. These are inserted between the codes [const INVALID] and
[const CHECK_DIGIT].

[comment {==================================================================}]
[call [cmd valtype::common::badlength] [arg code] [arg lengths] [opt [arg text]]]

This command throws an [const {INVALID LENGTH}] error with the
specified [arg text], if any, extended by the standard text "incorrect
length, expected ... character(s)". The first argument is a list of
codes providing details.

These are inserted between the codes [const INVALID] and
[const LENGTH]. The argument [arg lengths] is a list of the input
lengths which had been expected, i.e. these are the valid lengths.

[comment {==================================================================}]
[call [cmd valtype::common::badprefix] [arg code] [arg prefixes] [opt [arg text]]]

This command throws an [const {INVALID PREFIX}] error with the
specified [arg text], if any, extended by the standard text "incorrect
prefix, expected ...". The first argument is a list of codes providing
details.

These are inserted between the codes [const INVALID] and
[const PREFIX]. The argument [arg prefixes] is a list of the input
prefixes which had been expected, i.e. these are the valid prefixes.

[list_end]

[section {Error Codes}]

The errors thrown by the commands of this package all use the
[cmd -errorcode] [const INVALID] to distinguish the input validation
failures they represent from package internal errors.

[para] To provide more detailed information about why the validation
failed the [cmd -errorCode] goes actually beyond that.

First, it will contain a code detailing the type itself. This is
supplied by the caller. This is then followed by values detailing the
reason for the failure. The full set of [cmd -errorCode]s which can be
thrown by this package are shown below, with [const <>] a placeholder
for both the caller-supplied type-information, the type description.

[vset CODE [const <>]]
[vset A a]
[vset NAME [const <>]]
[list_begin definitions]
[def "INVALID [vset CODE] CHARACTER"]

The input value contained one or more bad characters, i.e. characters
which must not occur in the input for it to be [vset A] [vset NAME].

[def "INVALID [vset CODE] CHECK-DIGIT"]

The check digit of the input value is wrong. This usually signals a
data-entry error, with digits transposed, forgotten, etc. Of course,
th input may be an outright fake too.

[include include/c_lenpfx.inc]
[list_end]

[vset CATEGORY valtype]
[include ../common-text/feedback.inc]
[manpage_end]