valtype::creditcard::amex(n)
β¨ valtype::creditcard::amex β¨
okay bestie, so this is the n manual page for valtype::creditcard::amex β it lives in the Validation types section of the manual, and it's the whole entire vibe of validating an AMEX creditcard number. π
π NAME
valtype::creditcard::amex β Validation for AMEX creditcard number
πΈ SYNOPSIS
package require Tcl 8.5 9
package require snit 2
package require valtype::common
package require valtype::luhn
package require valtype::creditcard::amex ?1.1?
valtype::creditcard::amex validate value
valtype::creditcard::amex checkdigit value
π¦ DESCRIPTION
So this package implements a snit validation type for an AMEX creditcard number. No cap, that's the whole job. π³
A validation type is basically an object you can use to validate Tcl values of a particular kind. For example, snit::integer β a validation type defined by the snit package β is used to validate that a Tcl value is an integer. Same energy, different data. β¨
Every validation type has a validate method, and that's the method you use to actually do the validating. This method must take a single argument: the value to be validated. And then β and this is the important part, bestie β it must do nothing if the value is valid, but throw an error if the value is invalid:
valtype::creditcard::amex validate .... ;# Does nothing
valtype::creditcard::amex validate .... ;# Throws an error (bad American Expresss creditcard number).
not me pointing out that the original really does say "American Expresss" with the triple s. we keep it. character for character. π
The validate method will always return the validated value on success, and throw the -errorcode INVALID on error β possibly with additional elements which provide more details about the problem. π΅οΈ
π API
The API provided by this package satisfies the specification of snit validation types found in the documentation of Snit's Not Incr Tcl. Iconic behavior, honestly.
valtype::creditcard::amex 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 is thrown. Periodt. π«Άvaltype::creditcard::amex checkdigit valueβ This method computes a check digit for the value. Before doing so it is validated, except for a checkdigit. If the value does not pass the validation no check digit is calculated and an error is thrown instead. So like, no check digit for you if you're fake. π
π ERROR CODES
As said in the package description, 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. π¨
To provide more detailed information about why the validation failed, the -errorCode goes actually beyond that. First, it will contain a code detailing the type itself. Here this is CREDITCARD AMEX. This is then followed by values detailing the reason for the failure. The full set of -errorCodes which can be thrown by this package are:
INVALID CREDITCARD AMEX 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 AMEX creditcard number. Rude little gremlins in your string. πINVALID CREDITCARD AMEX 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, "th input". we said what we said. π)INVALID CREDITCARD AMEX LENGTHβ The input value is of the wrong length to be an AMEX creditcard number. Too short, too long, just not the vibe check. πINVALID CREDITCARD AMEX PREFIXβ The input value does not start with the magic value(s) required for it to be an AMEX creditcard number. Wrong opening act, bestie. π
π 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 [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation. We want the feedback, 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. iykyk. π
π₯ KEYWORDS
AMEX, American Express, Checking, Testing, Type checking, Validation, Value checking, bank, card for credit, credit card, finance, isA
π CATEGORY
Validation, Type checking
β COPYRIGHT
Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
okay that's the whole page, bestie!! this one came out of tcllib version 1.1, and the page itself is valtype::creditcard::amex(n) β main character energy from start to finish. go validate something. 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