valtype::creditcard::visa(n)

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

πŸ’³ valtype::creditcard::visa(n) β€” Validation types πŸ’³

okay bestie, gather round, because today we're talking about valtype::creditcard::visa, a manual page from the Validation types section, and honestly? it's giving "small package, big opinions about your card number." no cap.


✨ NAME ✨

valtype::creditcard::visa β€” Validation for VISA 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::visa ?1.1?

valtype::creditcard::visa validate value

valtype::creditcard::visa checkdigit value

πŸ’– DESCRIPTION πŸ’–

so basically, this package implements a snit validation type for a VISA creditcard number. that's the whole vibe. πŸ’…

and what even is a validation type? it's an object you can use to validate Tcl values of a particular kind. like, snit::integer β€” a validation type defined by the snit package β€” gets used to validate that a Tcl value is an integer. same energy, different target. ✨

every validation type has a validate method, and that's the one doing the actual validating. rules of the game, fr fr:

  • it must take a single argument, the value to be validated
  • it must do nothing if the value is valid
  • it must throw an error if the value is invalid

like so:

valtype::creditcard::visa validate .... ;# Does nothing
valtype::creditcard::visa validate .... ;# Throws an error (bad VISA creditcard number).

the validate method will always return the validated value on success, and on error it throws the -errorcode INVALID, possibly with extra elements giving more deets about what went wrong. πŸ‘‘


πŸ¦‹ API πŸ¦‹

the API this package provides satisfies the spec of snit validation types found in the documentation of Snit's Not Incr Tcl. iconic.

  • valtype::creditcard::visa validate value β€” this method validates the value and returns it, possibly in a canonical form, if it passes. if the value does not pass, an error is thrown. no passing, no returning. 😀
  • valtype::creditcard::visa checkdigit value β€” this method computes a check digit for the value. before it does that, the value gets validated, except for a checkdigit. if the value doesn't pass validation, no check digit gets calculated and an error is thrown instead. so yeah, no sneaky checkdigit-free shortcuts. πŸŽ€

🚨 ERROR CODES 🚨

like the package description said, 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. separating the drama from the actual bugs, love that for us.

and to give you more detailed info about why the validation failed, the -errorCode goes actually beyond that. first, it contains a code detailing the type itself β€” here that's CREDITCARD VISA. then that's followed by values detailing the reason for the failure. the full set of -errorCodes this package can throw:

  • INVALID CREDITCARD VISA 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 VISA creditcard number. πŸ’€
  • INVALID CREDITCARD VISA 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. (and yes, the original really does say "th input" β€” we don't fix typos here, we preserve them with love πŸ™ˆ)
  • INVALID CREDITCARD VISA LENGTH β€” the input value is of the wrong length to be a VISA creditcard number. too short, too long, just not it. 😭
  • INVALID CREDITCARD VISA PREFIX β€” the input value does not start with the magic value(s) required for it to be a VISA 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 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 feedback, we love ideas, we love you. 🫢

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. yes that's very specific, and yes, do it that way. πŸ’…

πŸ”‘ KEYWORDS πŸ”‘

Checking, Testing, Type checking, VISA, 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 and that's the whole page!! from tcllib, version 1.1 β€” the source and version living down in the footer of the original, and this is me handing them to you with a little bow on top πŸŽ€ no date on the footer, just pure tcllib 1.1 energy. mwah, bye bestie, go validate some card numbers responsibly πŸ’–

πŸ“¦ where this page comes from