valtype::gs1::ean13(n)
β¨ valtype::gs1::ean13 β¨
okay bestie, welcome to the manual page for valtype::gs1::ean13(n) β yes that's the manual name, it's giving very "I live in section n of the tcllib docs" π
and we're gonna get you fluent in it. buckle up, it's shorter than you think and lowkey cute.
πΈ NAME πΈ
valtype::gs1::ean13 β Validation for EAN13
π SYNOPSIS π
package require Tcl 8.5 9
package require snit 2
package require valtype::common
package require valtype::gs1::ean13 ?1.1?
valtype::gs1::ean13 validate value
valtype::gs1::ean13 checkdigit value
π¦ DESCRIPTION π¦
So this package implements a snit validation type for an EAN13. periodt.
And what even is a validation type, you ask? great question, bestie. A validation type is an object that can be used to validate Tcl values of a particular kind. like, for example, snit::integer β that's a validation type defined by the snit package, and it's used to validate that a Tcl value is an integer. same energy, different data. β¨
Every validation type has a validate method, and that's the thing doing the actual validating. This method must take a single argument β the value to be validated β and further, it must do nothing if the value is valid, but throw an error if the value is invalid. literally that simple:
valtype::gs1::ean13 validate .... ;# Does nothing
valtype::gs1::ean13 validate .... ;# Throws an error (bad EAN13).
The validate method will always return the validated value on success, and throw the -errorcode INVALID on error β possibly with additional elements which provide more details about the problem. so like, it's not just gonna say "no", it'll tell you why. π
π API π
The API provided by this package satisfies the specification of snit validation types found in the documentation of Snit's Not Incr Tcl. iykyk.
valtype::gs1::ean13 validate valueβ This method validates the value and returns it, possibly in a canonical form, if it passes. If the value does not pass the validation an error is thrown. no notes, flawless behaviour fr fr.valtype::gs1::ean13 checkdigit valueβ This method computes a check digit for the value. But before it does any of that, the value gets validated β except for a checkdigit. So if the value does not pass the validation, no check digit is calculated and an error is thrown instead. rude but fair. π«Ά
π ERROR CODES π
As said in the package description, the errors thrown by the commands of this package in response to input validation failures use the -errorcode INVALID to distinguish themselves from package internal errors. gotta know which one's which, bestie.
To provide more detailed information about why the validation failed, the -errorCode goes actually beyond that. First, it will contain a code detailing the type itself. Here this is EAN13. This is then followed by values detailing the reason for the failure. The full set of -errorCodes which can be thrown by this package are:
INVALID EAN13 CHARACTERβ The input value contained one or more bad characters, i.e. characters which must not occur in the input for it to be an EAN13. π«INVALID EAN13 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. π (and yes, the original says "th input", we do not fix the manpage, we respect the manpage. π)INVALID EAN13 LENGTHβ The input value is of the wrong length to be an EAN13. not every number gets to be thirteen digits, and that's the vibe check right there.
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. (iconic of docs honestly π). Please report such in the category valtype of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation. we love feedback, bring it.
When proposing code changes, please provide unified diffs, i.e the output of diff -u. that's the whole assignment.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. (yes, the left-most one. don't make me come over there. π)
π₯ KEYWORDS π₯
Checking, EAN, EAN13, European Article Number, International Article Number, Testing, Type checking, Validation, Value checking, isA
π CATEGORY π
Validation, Type checking
π COPYRIGHT π
Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
okay that's the whole page bestie, you ate it. π
β¨ source is tcllib, version 1.1, and this whole page is living its best life as valtype::gs1::ean13(n) β go forth and validate, no cap. π¦πΈπ
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2011 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms