valtype::gs1::ean13(3tcl)
π valtype::gs1::ean13 π
okay bestie, so you know the valtype::gs1::ean13 manual page? that's the one. this is her. she lives in 3tcl land and she is Validation types coded. pull up a chair, we're doing barcode validation and it's lowkey iconic π
β¨ NAME β¨
valtype::gs1::ean13 β validation for EAN13, no cap π
πΈ 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
like, that's the whole vibe right there. ?1.1? means the version is optional btw, she's flexible π¦
π DESCRIPTION π
so this package implements a snit validation type for an EAN13. that's it, that's the girl π«Ά
now, a validation type is just an object you use to validate Tcl values of one specific kind. for example, snit::integer β which is a validation type that the snit package defines β gets used to check that some Tcl value is actually an integer. same energy, different flavour.
every validation type has a validate method, and that's the one doing the actual work. the rules are simple, bestie:
- it must take a single argument, which is the value being validated
- it must do absolutely nothing if the value is valid
- but it must throw an error if the value is invalid
watch:
valtype::gs1::ean13 validate .... ;# Does nothing
valtype::gs1::ean13 validate .... ;# Throws an error (bad EAN13).
see how that works? one of those is chill, one of those is a whole meltdown π
on success, validate will always return the validated value. on failure it throws with -errorcode INVALID, and sometimes there's extra stuff tacked on giving you more detail about what went wrong. it's giving helpful, honestly.
π API π
the API this package hands you fully satisfies the spec for snit validation types, the one written up in the documentation of Snit's Not Incr Tcl. so if you've read that, you already know the shape of things. iykyk.
valtype::gs1::ean13 validate valueβ validates the value and returns it if it passes, possibly in a canonical form. if the value flops the validation, an error gets thrown. simple as πvaltype::gs1::ean13 checkdigit valueβ computes a check digit for the value. before it does any of that, it validates the value β except for the checkdigit itself, obviously, because how are you gonna validate a digit you haven't calculated yet π. if the value doesn't pass, no check digit gets calculated and an error is thrown instead. periodt.
π₯ ERROR CODES π₯
like the package description said, the errors these commands throw when input validation fails use -errorcode INVALID so they can tell themselves apart from the package's own internal errors. main character boundaries, honestly π
but to give you the why of the failure, the -errorCode actually goes further than that. first it carries a code naming the type itself β here that's EAN13 β and then it's followed by values describing the reason for the failure. the complete set of -errorCodes this package can throw is:
INVALID EAN13 CHARACTERβ the input value had one or more bad characters, meaning characters that must not occur in the input for it to be an EAN13. like, girl, what is that letter doing there π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. and of course, the input might just be an outright fake too. caught in 4k πINVALID EAN13 LENGTHβ the input value is the wrong length to be an EAN13. too short, too long, not the moment π
π BUGS, IDEAS, FEEDBACK π
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's giving humble. please report them in the category valtype of the Tcllib Trackers:
http://core.tcl.tk/tcllib/reportlist
and please also report any ideas for enhancements you have for either the package and/or the documentation. we want the glow up β¨
when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. that's the love language.
also note: attachments are strongly preferred over inlined patches. to attach something, go to the Edit form of the ticket immediately after you create it, then use the left-most button in the secondary navigation bar. that's the one, bestie π«Ά
β 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>
and that's the whole page, bestie π this was tcllib, version 1.1, dated back in the day, and she's filed under valtype::gs1::ean13(3tcl). go validate something iconic π¦β¨
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- 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