valtype::iban(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

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