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

NAME

8       valtype::gs1::ean13 - Validation for EAN13
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::gs1::ean13  ?1?
18
19       valtype::gs1::ean13 validate value
20
21       valtype::gs1::ean13 checkdigit value
22
23______________________________________________________________________________
24

DESCRIPTION

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

API

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

ERROR CODES

63       As  said  in the package description, the errors thrown by the commands
64       of this package in  response  to  input  validation  failures  use  the
65       -errorcode  INVALID  to  distinguish  themselves  from package internal
66       errors.
67
68       To provide more detailed information about why  the  validation  failed
69       the  -errorCode  goes  actually  beyond that.  First, it will contain a
70       code detailing the type itself. Here this is EAN13. This is  then  fol‐
71       lowed  by  values detailing the reason for the failure. The full set of
72       -errorCodes which can be thrown by this package are:
73
74       INVALID EAN13 CHARACTER
75              The input value contained one or more bad characters, i.e. char‐
76              acters which must not occur in the input for it to be an EAN13.
77
78       INVALID EAN13 CHECK-DIGIT
79              The  check  digit of the input value is wrong. This usually sig‐
80              nals a data-entry error, with digits transposed, forgotten, etc.
81              Of course, th input may be an outright fake too.
82
83       INVALID EAN13 LENGTH
84              The input value is of the wrong length to be an EAN13.
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,  EAN,  EAN13,  European Article Number, International Article
103       Number, Testing, Type checking, Validation, Value checking, isA
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::gs1::ean13(n)
Impressum