valtype::common(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– 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 an INVALID error with the text you gave it. the first argument, code, is a list of codes that extends the INVALID with extra detail info. this is the one everything else is built on, periodt.
  • valtype::common::badchar code ?text? β€” throws an INVALID CHAR error with the specified text. the first argument is a list of codes providing details, and those get inserted between the codes INVALID and CHARACTER. cute, right? πŸ¦‹
  • valtype::common::badcheck code ?text? β€” throws an INVALID CHECK-DIGIT error with the specified text, if there is any, extended by the standard text the check digit is incorrect. the first argument is a list of codes providing details, inserted between the codes INVALID and CHECK_DIGIT. 😭
  • valtype::common::badlength code lengths ?text? β€” throws an INVALID LENGTH error with the specified text, if any, extended by the standard text incorrect length, expected ... character(s). the first argument is a list of codes providing details, inserted between INVALID and LENGTH. now, lengths is 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 an INVALID PREFIX error with the specified text, if any, extended by the standard text incorrect prefix, expected .... the first argument is a list of codes providing details, inserted between INVALID and PREFIX. and prefixes here 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 (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