CC_VISA(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’³ valtype::creditcard::visa β€” the valtype::creditcard::visa manual, section 3tcl, bestie edition ✨

okay so. you opened the manual for valtype::creditcard::visa and you want the whole thing but make it make sense? say less. this is Validation for VISA creditcard number, it lives in section 3tcl, and it ships with tcllib. let's go 🫢


✨ 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. This package implements a snit validation type for a VISA creditcard number. That's the whole vibe. πŸ‘‘

And like, what even is a validation type? Bestie. A validation type is 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 β€” gets used to validate that a Tcl value is an integer. Same energy, different data type. ✨

Every validation type has a validate method, and that's the one doing the actual work. Rules of the game:

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

so it's giving:

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 with -errorcode INVALID, possibly with extra elements that spill more tea about what exactly went wrong. πŸ’€


🌈 API 🌈

The API this package gives you satisfies the spec of snit validation types found in the documentation of Snit's Not Incr Tcl. no cap.

  • valtype::creditcard::visa validate value β€” This method validates the value and returns it, possibly in a canonical form, if it passes. And if the value does not pass the validation? an error is thrown. simple as. πŸŽ€
  • valtype::creditcard::visa 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 does not pass validation then no check digit is calculated and an error is thrown instead. periodt. πŸ’…

πŸ‘‘ ERROR CODES πŸ‘‘

Like the package description already said, the errors thrown by this package's commands when input validation fails use -errorcode INVALID to distinguish themselves from the package's own internal errors. important distinction, don't skip it.

Now for the extra detail, because -errorCode goes actually beyond that. First, it will contain a code detailing the type itself. Here, that's CREDITCARD VISA. After that comes 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, the input may be an outright fake too. 😭
  • INVALID CREDITCARD VISA LENGTH β€” The input value is of the wrong length to be a VISA creditcard number.
  • INVALID CREDITCARD VISA PREFIX β€” The input value does not start with the magic value(s) required for it to be a VISA creditcard number. 🧚

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

This document, and the package it describes, will undoubtedly contain bugs and other problems. not me being honest about it πŸ™ˆ Please report such in the category valtype of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. And please also report any ideas for enhancements you may have for either the package and/or the documentation. we love 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 πŸ”₯

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 bestie that's the whole page, every flag, every error code, every reference, nothing skipped πŸ’œ go validate some cards and stay iconic ✨

tcllib Β· version 1.1 Β· page valtype::creditcard::visa(3tcl) β€” mwah, take care of her πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from