valtype::iban(3tcl)

๐Ÿ“ฆ
version 2.0 ยท 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– 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 (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