valtype::common(3tcl)
π valtype::common π
okay bestie, buckle up, because this is the manual page for valtype::common β that's the valtype::common page out of the Validation types manual. it's the shared glue code that all the other validation types in this module lean on, and honestly? it's giving backstage crew energy. not the star of the show, but literally nothing works without it. π
β¨ NAME β¨
valtype::common β Validation, common code. that's it, that's the name, short and iconic. π
πΈ SYNOPSIS πΈ
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?
π¦ DESCRIPTION π¦
so this package implements a bunch of common commands that all the validation types in this module use. the whole point of these commands is that they basically encapsulate the throwing of validation errors β meaning they make sure a proper -errorcode gets used every single time, no cap. no sloppy ad-hoc error throwing around here, we have standards. π
if you wanna know exactly which error codes come out of this, go peep the section called Error Codes. it's right down there, it ate. π₯
π API π
valtype::common::reject code text
the core command of this package, periodt. it throws an INVALID error with the text you specified. the first argument, code, is a list of codes that extends the INVALID with detail information. it's the main character of this whole file, fr fr. β¨
valtype::common::badchar code ?text?
this one throws an INVALID CHAR error with the text you gave it. first argument is a list of codes providing details β and those details get inserted between the codes INVALID and CHARACTER. cute, right? it's like a little code sandwich. π₯ͺ
valtype::common::badcheck code ?text?
this throws an INVALID CHECK-DIGIT error with the text, if any, extended by the standard text "the check digit is incorrect". first argument is a list of codes providing details, and those get inserted between the codes INVALID and CHECK_DIGIT. so your text gets a lil bonus sentence appended. obsessed. π
valtype::common::badlength code lengths ?text?
throws an INVALID LENGTH error with the text, if any, extended by the standard text "incorrect length, expected ... character(s)". first argument is a list of codes providing details, inserted between the codes INVALID and LENGTH. and lengths? that's a list of the input lengths which had been expected β aka the valid lengths. so basically "here's what it should have been, bestie". π
valtype::common::badprefix code prefixes ?text?
throws an INVALID PREFIX error with the text, if any, extended by the standard text "incorrect prefix, expected ...". first argument is a list of codes providing details, inserted between the codes INVALID and PREFIX. and prefixes is a list of the input prefixes which had been expected β i.e. the valid ones. start your string right or don't start it at all. π
π ERROR CODES π
the errors thrown by the commands of this package all use the -errorcode INVALID to distinguish the input validation failures they represent from package internal errors. so when you see INVALID, that's a you gave me bad input situation, not a the package is broken situation. vibe check passed. β
to provide more detailed information about why the validation failed, the -errorCode actually goes beyond that. first, it'll contain a code detailing the type itself β that one is supplied by the caller. then it's followed by values detailing the reason for the failure. the full set of -errorCodes which can be thrown by this package are shown below, with <> as a placeholder for both the caller-supplied type-information and the type description.
heads up: that <> is literally a placeholder in the docs, bestie β it's not syntax you type. it's where your type info goes. π
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 <>. some characters just weren't invited to the party. π
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, th input may be an outright fake too. (yes, "th" β we're quoting the original typo because we keep everything, and honestly it's lowkey a mood. π)
INVALID <> LENGTH
the input value is of the wrong length to be a <>. too short, too long, just not it. π
INVALID <> PREFIX
the input value does not start with the magic value(s) required for it to be a <>. wrong opening act, cancelled. π«
π«Ά BUGS, IDEAS, FEEDBACK π«Ά
this document, and the package it describes, will undoubtedly contain bugs and other problems. (self-aware queens, we love to see it. π)
please report such in the category valtype of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. please also report any ideas for enhancements you may have for either package and/or documentation. we want the ideas, give us the ideas. π§
when proposing code changes, please provide unified diffs β i.e. the output of diff -u. no freestyle, we want the diff. π₯
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. that's the move, trust. β¨
β 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 came to you courtesy of tcllib, version 1.1 of valtype::common(3tcl) β go forth and validate responsibly. mwah. π
π¦πΈ
π¦ 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