valtype::iban(3tcl)
๐ valtype::iban โ the manual, bestie edition ๐
okay so this is the page for valtype::iban, part of the Tcllib validation-types fam (that's the 3tcl manual section, iykyk). It's the whole vibe of "is this string actually an IBAN or are you playing games" and honestly? iconic. ๐
โจ NAME โจ
valtype::iban โ validation for IBAN, no cap ๐
๐ฆ SYNOPSIS ๐ฆ
package require Tcl 8.5 9
package require snit 2
package require valtype::common
package require valtype::iban ?1.8?
valtype::iban validate value
valtype::iban checkdigit value
๐ธ DESCRIPTION ๐ธ
So this package implements a snit validation type for an IBAN. That's it, that's the job, and it does it gorgeously. ๐
A validation type is basically an object you can use to validate Tcl values of one particular kind. Like, snit::integer โ a validation type that the snit package itself defines โ gets used to check that a Tcl value is an integer. Same energy, but for bank account numbers. ๐ฆโจ
Every validation type has a validate method, and that's the method you use to do the actual validating. It has to take exactly one argument: the value you want checked. And here's the deal โ it must do nothing if the value is valid, but throw an error if the value is invalid:
valtype::iban validate .... ;# Does nothing
valtype::iban validate .... ;# Throws an error (bad International Bank Account Number).
The validate method will always return the validated value on success, and on error it throws with -errorcode INVALID, possibly with extra elements tacked on that give you more detail about what went wrong. It's giving "I'm not mad, I'm just disappointed, and also here's a whole diagnostic report". ๐
๐ API ๐
The API this package provides satisfies the spec of snit validation types found in the documentation of Snit's Not Incr Tcl. (You know the one.)
valtype::iban validate valueโ this method validates the value and returns it, possibly in a canonical form, if it passes. If the value does not pass validation, an error gets thrown. Simple as that, bestie. โvaltype::iban checkdigit valueโ this method computes a check digit for the value. Before it does that, it validates the value โ except for a checkdigit. If the value doesn't pass validation, then no check digit gets calculated and an error is thrown instead. No math for bad input, periodt. ๐ซ๐งฎ
๐ ERROR CODES ๐
Like the package description said, the errors thrown by this package's commands in response to input validation failures use -errorcode INVALID to distinguish themselves from package internal errors. ๐จ
But to give you the more detailed tea about why the validation failed, the -errorCode actually goes beyond that. First, it'll contain a code detailing the type itself. Here that's IBAN. Then it's followed by values detailing the reason for the failure. The full set of -errorCodes this package can throw is:
INVALID IBAN CHARACTERโ the input value contained one or more bad characters, i.e. characters which must not occur in the input for it to be an IBAN. Rude little gremlins. ๐INVALID IBAN 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, that's "th", we're keeping it exactly as written, it's part of the charm)
๐ BUGS, IDEAS, FEEDBACK ๐
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. Please also report any ideas for enhancements you may have for either package and/or documentation. We wanna hear it, 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.
โญ KEYWORDS โญ
Checking, IBAN, International Bank Account Number, Testing, Type checking, Validation, Value checking, bank, finance, 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.8, dated with all the love โ go validate something and slay ๐ ๐ฆ
๐ฆ 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