valtype::verhoeff(n)
π valtype::verhoeff β bestie, it's a validation type era π
This is the manual page for valtype::verhoeff(n) from the Validation types family, and yes we're gonna read the whole thing together, no skipping, it's not that kind of party. π
β¨ NAME β¨
valtype::verhoeff β validation for a plain number that's rockin' a VERHOEFF checkdigit π
πΈ SYNOPSIS πΈ
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
(the ?1.1? means that version is optional, she's flexible like that π¦)
π DESCRIPTION π
Okay so, this package implements a snit validation type for a plain number with a VERHOEFF checkdigit. Slay.
A validation type is basically an object you can use to validate Tcl values of a particular kind. Like, for example, snit::integer is a validation type defined by the snit package, and it's used to validate that a Tcl value is an integer. She checks IDs, essentially. π
Every single validation type has a validate method that does the validating. This method must take a single argument β the value to be validated. And further, bestie, it must do nothing if the value is valid, but throw an error if the value is invalid:
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 it'll throw the -errorcode INVALID on error β possibly with extra elements that spill more tea about what exactly went wrong. π
π₯ API π₯
The API this package serves up satisfies the spec of snit validation types found in the documentation of Snit's Not Incr Tcl. Periodt.
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 gets thrown. No in-between, no "almost valid", she doesn't do participation trophies. πvaltype::verhoeff checkdigit valueβ This method computes a check digit for the value. Before it does any of that, the value gets validated β except for a checkdigit. If the value doesn't pass validation, no check digit is calculated and an error is thrown instead. So like, fix the input first, then we'll talk. π
β 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. Iconic of them honestly. π
But to give you more detailed info about why the validation flopped, the -errorCode actually goes beyond that. First, it'll contain a code detailing the type itself. Here, that's VERHOEFF. Then it's followed by values detailing the reason for the failure. The full set of -errorCodes this package can throw 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. Rude little characters, not invited to the function. π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. π Not naming names but... some values are lying.
π¦ BUGS, IDEAS, FEEDBACK π¦
This document, and the package it describes, will undoubtedly contain bugs and other problems. (not me being self-aware, we love growth π±) 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're listening, 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. That's the vibe check right there. β¨
π KEYWORDS π
Checking, Testing, Type checking, Validation, Value checking, isA, verhoeff
π CATEGORY π
Validation, Type checking
π COPYRIGHT π
Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
And that's the whole page bestie, you ate it. π
This was tcllib version 1.1 of valtype::verhoeff(n) β go forth and validate, main character. π π¦ππ
π¦ 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