CC_MASTERCARD(n)
π³ NAME π³
okay bestie so like β valtype::creditcard::mastercard is the validation type for a Mastercard creditcard number. yes that's the whole vibe. this is the manual page for valtype::creditcard::mastercard(n) and she's iconic, she checks your card numbers, she does not play. π
β¨ 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 implements a snit validation type for a Mastercard creditcard number. That's the whole job, and she does it well. π«Ά
A validation type is like... an object that can validate Tcl values of a particular kind. Lowkey the best 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 flavor. β¨
Every validation type has a validate method, and that method is what you use to do the validating. The rules, no cap:
- it takes a single argument β the value to be validated
- it does nothing if the value is valid
- it throws 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 throws the -errorcode INVALID on error, possibly with additional elements which provide more details about the problem. it's giving thorough. π
π API π
The API provided by this package satisfies the specification of snit validation types found in the documentation of Snit's Not Incr Tcl. fr fr, it's spec-compliant.
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 is thrown. no notes. πvaltype::creditcard::mastercard 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. she said "no valid input, no math" periodt. π
π¨ ERROR CODES π¨
Like we said up 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. main character energy for real. π
But 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 MASTERCARD. 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 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. ma'am that is not a digit. πINVALID CREDITCARD MASTERCARD 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. πINVALID CREDITCARD MASTERCARD LENGTHβ The input value is of the wrong length to be a Mastercard creditcard number. too short or too long bestie, pick a struggle. πINVALID CREDITCARD MASTERCARD PREFIXβ The input value does not start with the magic value(s) required for it to be a Mastercard creditcard number. the magic prefix said absolutely not. β
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. (she's humble like that.) 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 love a suggestion box era. π
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>
okay that's the whole page bestie, go forth and validate. this was tcllib, version 1.1, for valtype::cre...d::mastercard(n) β slay, obsessed, see you in the next manpage. πβ¨π¦
π¦ 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