valtype::creditcard::amex(n)

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

✨ 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 (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