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

NAME

8       valtype::isbn - Validation for ISBN
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::isbn  ?1?
18
19       valtype::isbn validate value
20
21       valtype::isbn checkdigit value
22
23       valtype::isbn 13of value
24
25______________________________________________________________________________
26

DESCRIPTION

28       This package implements a snit validation type for an ISBN.
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::isbn validate .... ;# Does nothing
42                  valtype::isbn validate .... ;# Throws an error (bad ISBN).
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::isbn 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::isbn 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
64       valtype::isbn 13of value
65              This  method  expects an old-style 10-digit ISBN and returns the
66              canonical modern 13-digit ISBN.  This is  used  by  validate  to
67              canonicalize  the  input,  so that all parts of the system after
68              the validation can expect to work with modern 13-digit ISBNs.
69

ERROR CODES

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

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

110       Book Number, Checking,  EAN,  EAN13,  European  Article  Number,  ISBN,
111       International Article Number, International Standard Book Number, Test‐
112       ing, Type checking, Validation, Value checking, isA
113

CATEGORY

115       Validation, Type checking
116
118       Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
119
120
121
122
123tcllib                                 1                      valtype::isbn(n)
Impressum