valtype::imei(3tcl)

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

πŸ’– valtype::imei β€” the manual page, but make it cute πŸ’–

okay so bestie, gather round, because we're about to talk about valtype::imei, which is the valtype::imei(3tcl) manual page from tcllib, version 1.1. she validates IMEIs. she's a snit validation type. she's lowkey iconic and she has ✨opinions✨ about your check digit.


πŸŽ€ NAME πŸŽ€

valtype::imei β€” validation for IMEI. that's it, that's the whole job, and she ate. πŸ’…


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require snit 2

package require valtype::common

package require valtype::luhn

package require valtype::imei ?1.1?

valtype::imei validate value

valtype::imei checkdigit value

πŸ¦‹ DESCRIPTION πŸ¦‹

So. This package implements a snit validation type for an IMEI. periodt.

And what even is a validation type, you ask? okay so a validation type is an object you can use to validate Tcl values of one particular kind. the classic example: snit::integer, which is a validation type defined by the snit package, and it's used to check that a Tcl value is actually an integer. same energy, different number. 🧚

Every validation type has a validate method, and that's the method that does the validating. It must take a single argument β€” the value to be validated β€” and then: if the value is valid it does nothing, but if the value is invalid it throws an error:

valtype::imei validate .... ;# Does nothing
valtype::imei validate .... ;# Throws an error (bad International Mobile Equipment Identity (IMEI) number).

The validate method will always return the validated value when it succeeds, and when it fails it throws the -errorcode INVALID, possibly with extra elements attached that give you more details about what went wrong. it's giving "here's the receipt, bestie". 🧾


πŸ”₯ API πŸ”₯

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

  • valtype::imei validate value β€” this method validates the value and returns it if it passes, possibly in a canonical form. If the value does not pass, an error gets thrown. no half measures, no vibes-only validation.
  • valtype::imei 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. And if the value fails validation? no check digit for you, boo β€” an error is thrown instead. 😭

πŸ’€ 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 so they can tell themselves apart from the package's own internal errors.

But to give you more detailed info about why the validation flopped, the -errorCode actually goes beyond that. First, it will contain a code detailing the type itself. Here, that's IMEI. Then it's followed by values detailing the reason for the failure. The full set of -errorCodes which can be thrown by this package are:

  • INVALID IMEI CHARACTER β€” the input value contained one or more bad characters, i.e. characters which must not occur in the input for it to be an IMEI. not the vibe. πŸ™ˆ
  • INVALID IMEI 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 IMEI LENGTH β€” the input value is of the wrong length to be an IMEI. she has a size and you did not respect it.

🫢 BUGS, IDEAS, FEEDBACK 🫢

This document, and the package it describes, will undoubtedly contain bugs and other problems. (yes, even this one, bestie β€” nobody's perfect.) 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 the package and/or the documentation. we love ideas here. 🌈

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 button. the left-most one. you got this. πŸ‘‘


⭐ KEYWORDS ⭐

  • Checking
  • IMEI
  • International Mobile Equipment Identity
  • Testing
  • Type checking
  • Validation
  • Value checking
  • cell-phone
  • isA
  • mobile phone
  • phone

🌈 CATEGORY 🌈

Validation, Type checking


Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>


and that's the whole page, bestie β€” tcllib 1.1, manual page valtype::imei(3tcl), and it's a whole serve. go forth and validate responsibly. πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from