valtype::iban(n)
π valtype::iban β the manual page, but make it make sense π
okay so bestie, you're looking at valtype::iban(n), which lives in the Validation types section of the manual (the (n) means it's a Tcl package doc, iykyk). This is the one that checks whether a string is actually an IBAN β an International Bank Account Number β or just some random keyboard smash. Let's get into it. π¦β¨
β¨ NAME β¨
valtype::iban β validation for IBAN. that's it, that's the whole vibe. π
πΈ 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 π¦
This package implements a snit validation type for an IBAN. π³
So like, a validation type is an object you can use to validate Tcl values of a particular kind. The classic example: snit::integer, a validation type that snit itself defines, is used to check that some Tcl value is an integer. Same energy, different currency. πͺ
Every validation type has a validate method, and that's the thing doing the actual validating. Rules of the game, no cap:
- it must take a single argument β the value to be validated π«Ά
- it must do nothing if the value is valid
- it must throw an error if the value is invalid
Like so:
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 it throws the -errorcode INVALID on error β possibly with extra elements tacked on that give you more deets about what 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. iconic behavior honestly.
valtype::iban validate valueβ this method validates the value and returns it, possibly in a canonical form, if it passes. If it does not pass, an error gets thrown. no in-between, periodt. πvaltype::iban checkdigit valueβ this method computes a check digit for the value. Before it does any of that, it validates the value β except for a checkdigit. If the value doesn't pass validation, no check digit gets calculated and an error gets thrown instead. π
π ERROR CODES π
As said up in the package description, errors thrown by this package's commands in response to input validation failures use the -errorcode INVALID to distinguish themselves from package internal errors. π
But wait, there's more β to give you more detail on why the validation flopped, 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 are:
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. π«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 bestie, the original really does spell it "th input", we're keeping it, that's canon)
π 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 love a glow-up suggestion. π«Ά
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. (yes, the left-most one. that's the one. π )
π 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>
okay bestie that's the whole page, you ate it, you understood it, and honestly? iconic. this was tcllib, version 1.8, and the page is valtype::iban(n). go validate something and stay slay. πππ¦
π¦ 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