valtype::verhoeff(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– valtype::verhoeff β€” the manual, but make it cute πŸ’–

okay so bestie, you know how we're always like "is this even a real number??" β€” well this is the page for that. it's valtype::verhoeff, manual page valtype::verhoeff(3tcl), living in the 3tcl section, and it's all about validating a plain number that has a VERHOEFF checkdigit. slay. ✨


🌸 NAME 🌸

valtype::verhoeff β€” validation for a plain number with a VERHOEFF checkdigit. that's it, that's the whole name. iconic behavior honestly.


πŸŽ€ SYNOPSIS πŸŽ€

like, the whole vibe in one block:

package require Tcl 8.5 9

package require snit 2

package require valtype::common

package require valtype::verhoeff ?1.1?

valtype::verhoeff validate value

valtype::verhoeff checkdigit value

✨ DESCRIPTION ✨

so this package implements a snit validation type for a plain number with a VERHOEFF checkdigit. no cap. πŸ’…

and if you're like "girl what is a validation type" β€” okay so a validation type is an object that can be used to validate Tcl values of a particular kind. example: snit::integer, which is a validation type defined by the snit package, and it's used to validate that a Tcl value is an integer. see? it's giving "the vibe check but for values". πŸ¦‹

every validation type has a validate method, and that method is the one doing the actual validating. it must take a single argument β€” the value to be validated. and then: it must do nothing if the value is valid, but throw an error if the value is invalid. that's the whole rule bestie:

valtype::verhoeff validate .... ;# Does nothing
valtype::verhoeff validate .... ;# Throws an error (bad verhoeff checkdigit).

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 doesn't just say "no", it says "no and here's why". periodt. πŸ’€


πŸ‘‘ API πŸ‘‘

the API provided by this package satisfies the specification of snit validation types found in the documentation of Snit's Not Incr Tcl. (that's the actual title, we don't make the rules, we just validate them.)

  • valtype::verhoeff 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. simple as. 🫢
  • valtype::verhoeff 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, obviously, because it doesn't have one yet, that's literally the whole point. and if the value does not pass the validation, no check digit is calculated and an error is thrown instead. so rude but so fair. 😭

πŸ”₯ ERROR CODES πŸ”₯

like the package description already said, 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. so when you see INVALID, that's the "your input, bestie, not our code" signal. 🌈

and 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 VERHOEFF. then that's followed by values detailing the reason for the failure. the full set of -errorCodes which can be thrown by this package are:

  • INVALID VERHOEFF 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 plain number with a VERHOEFF checkdigit. not me putting a letter in a number field πŸ™ˆ
  • INVALID VERHOEFF 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, the original says "th input" β€” we keep it real, and we keep the meaning: the input might just be lying to you.)

πŸ’œ BUGS, IDEAS, FEEDBACK πŸ’œ

this document, and the package it describes, will undoubtedly contain bugs and other problems. like, obviously. 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 feedback fr fr. 🫢

when proposing code changes, please provide unified diffs, i.e the output of diff -u.

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. do it that way, it's the move. ✨


⭐ KEYWORDS ⭐

Checking, Testing, Type checking, Validation, Value checking, isA, verhoeff


πŸ¦‹ 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, manual page valtype::verhoeff(3tcl) β€” go validate something, you're doing amazing, mwah πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from