valtype::c...:mastercard(3tcl)
β¨ valtype::creditcard::mastercard β the glow-up β¨
okay bestie, you're in the valtype::c...:mastercard page of the 3tcl manual, and it's literally all about checking whether a Mastercard creditcard number is actually valid π³π
no cap.
πΈ NAME πΈ
valtype::creditcard::mastercard β Validation for Mastercard 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::mastercard ?1.1?
valtype::creditcard::mastercard validate value
valtype::creditcard::mastercard checkdigit value
π DESCRIPTION π
so this package ships a snit validation type for a Mastercard creditcard number, periodt.
A validation type is, like, an object that validates Tcl values of a particular kind. For example, snit::integer β a validation type defined by the snit package β is what you use to validate that a Tcl value is an integer. iconic behaviour honestly.
Every validation type has a validate method, and that's the main character that does the actual validating. It has to take a single argument β the value to be validated β and bestie listen: it must do nothing if the value is valid, but throw an error if the value is invalid:
valtype::creditcard::mastercard validate .... ;# Does nothing
valtype::creditcard::mastercard validate .... ;# Throws an error (bad Mastercard creditcard number).
The validate method will always return the validated value on success, and throw the -errorcode INVALID on error β possibly with extra elements attached that give you more details 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. slay.
valtype::creditcard::mastercard 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 gets thrown. simple as that πvaltype::creditcard::mastercard checkdigit valueβ This method computes a check digit for the value. Before it does any of that, the value gets validated β except for a checkdigit. If the value doesn't pass validation, then no check digit gets calculated at all, and an error is thrown instead. no check digit for you, bestie π
π ERROR CODES π
Like the package description already said, the errors thrown by the commands of this package when input validation fails use -errorcode INVALID to tell themselves apart from the package's own internal errors. vibe check: INVALID means you did something, not the package.
And to give you more detailed tea about why the validation failed, the -errorCode actually goes beyond that. First, it contains a code detailing the type itself β here that's CREDITCARD MASTERCARD. Then values follow detailing the reason for the failure. The full set of -errorCodes this package can throw:
INVALID CREDITCARD MASTERCARD CHARACTERβ The input value contained one or more bad characters, i.e. characters which must not occur in the input for it to be a Mastercard creditcard number. not the vibe. π«INVALID CREDITCARD MASTERCARD CHECK-DIGITβ The check digit of the input value is wrong. This usually signals a data-entry error β digits transposed, forgotten, etc. Of course, th input may be an outright fake too. πINVALID CREDITCARD MASTERCARD LENGTHβ The input value is of the wrong length to be a Mastercard creditcard number. too short, too long, whatever β it's giving wrong size πINVALID CREDITCARD MASTERCARD PREFIXβ The input value does not start with the magic value(s) required for it to be a Mastercard creditcard number. wrong opening act, bestie β¨
π«Ά BUGS, IDEAS, FEEDBACK π«Ά
This document, and the package it describes, will undoubtedly contain bugs and other problems β ngl, it's a whole thing. 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. iykyk π
π KEYWORDS π
Checking, MasterCard, 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>
and that's the whole page, bestie β every option, every error code, every word, no details left behind π
tcllib, version 1.1 β mwah, tysm for reading, slay the day π β¨πΈ
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- 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