CC_MASTERCARD(n)

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

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