valtype::common(n)
π valtype::common(n) β Validation types, but make it make sense β¨
okay bestie, pull up a chair π«Ά this is the manual page for valtype::common, a Tcl package from tcllib that's literally just Validation, common code. It's the shared glue that every validation type in the module leans on, so if you've ever wondered how those validators throw their errors so neatly β it's this. π
πΈ SYNOPSIS πΈ
here's the whole vibe up front, no cap:
package require Tcl 8.5 9
package require valtype::common ?1.1?
valtype::common::reject code text
valtype::common::badchar code ?text?
valtype::common::badcheck code ?text?
valtype::common::badlength code lengths ?text?
valtype::common::badprefix code prefixes ?text?
the?1.1?means the version is optional, and?text?means that argument is optional too. the way that Tcl manpages do that is giving "we can be flexible" π
β¨ DESCRIPTION β¨
so this package implements a bunch of common commands that the validation types in this module all use. What do they actually do? They basically encapsulate the throwing of validation errors β the whole point is making sure a proper -errorcode gets used every single time. No messy improvised errors here, we're a put-together package. π
if you wanna see the full list of codes, slide on down to the Error Codes section. iykyk. π
π API π
this is the main character section, bestie. every command, right here:
valtype::common::reject code textβ the core command of the entire package π₯ it throws anINVALIDerror with thetextyou gave it. the first argument,code, is a list of codes that extends theINVALIDwith extra detail info. this is the one everything else is built on, periodt.valtype::common::badchar code ?text?β throws anINVALID CHARerror with the specifiedtext. the first argument is a list of codes providing details, and those get inserted between the codesINVALIDandCHARACTER. cute, right? π¦valtype::common::badcheck code ?text?β throws anINVALID CHECK-DIGITerror with the specifiedtext, if there is any, extended by the standard textthe check digit is incorrect. the first argument is a list of codes providing details, inserted between the codesINVALIDandCHECK_DIGIT. πvaltype::common::badlength code lengths ?text?β throws anINVALID LENGTHerror with the specifiedtext, if any, extended by the standard textincorrect length, expected ... character(s). the first argument is a list of codes providing details, inserted betweenINVALIDandLENGTH. now,lengthsis a list of the input lengths that had been expected β so like, the valid lengths. it's giving "we told you what we wanted and you didn't deliver" πvaltype::common::badprefix code prefixes ?text?β throws anINVALID PREFIXerror with the specifiedtext, if any, extended by the standard textincorrect prefix, expected .... the first argument is a list of codes providing details, inserted betweenINVALIDandPREFIX. andprefixeshere is a list of the input prefixes which had been expected, i.e. the valid ones. πΈ
π₯ ERROR CODES π₯
every error thrown by this package's commands uses the -errorcode INVALID β that's how we tell "the input failed validation" apart from "the package itself broke". two completely different dramas, bestie, don't mix them up. π
and to spill even more tea about why the validation failed, the -errorCode goes actually beyond that. First, it'll contain a code detailing the type itself β that one's supplied by the caller. Then it's followed by values detailing the reason for the failure. Here's the full set of -errorCodes this package can throw, with <> standing in as a placeholder for both the caller-supplied type-information and the type description:
INVALID <> CHARACTERβ the input value contained one or more bad characters, i.e. characters which must not occur in the input for it to be a<>. π«INVALID <> 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, the input may be an outright fake too. π (yes, that's a real sentence in the original and i'm obsessed with the sass)INVALID <> LENGTHβ the input value is of the wrong length to be a<>.INVALID <> PREFIXβ the input value does not start with the magic value(s) required for it to be a<>. β¨
π BUGS, IDEAS, FEEDBACK π
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. π please report such in the category valtype of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. and please also report any ideas for enhancements you may have for either the package and/or the documentation. we want the glow-up. π
when proposing code changes, please provide unified diffs, i.e the output of diff -u. fr fr.
also 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. slay.
π§ KEYWORDS π§
Checking, 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, and if you need the manual name one more time for your bookmarks it's valtype::common(n) under Validation types. go validate something and make it iconic π
β¨
π¦ 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