valtype::imei(n)

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

πŸ’– valtype::imei β€” the manual page, bestie edition πŸ’–

okay so you're in the <pink>valtype::imei</pink> corner of the <purple>Validation types</purple> manual section, and honestly? it's giving "your phone's soul has a checksum and we're gonna verify it." slay.


✨ NAME ✨

valtype::imei β€” Validation for IMEI 🫢


🌸 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 basically this package implements a snit validation type for an IMEI. no cap.

A validation type is an object you can use to validate Tcl values of a particular kind. like, for 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's the one doing the actual validating. this method must take a single argument, the value to be validated; and further, it must do nothing if the value is valid, but throw an error if the value is invalid:

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 on success ✨ and throw the -errorcode INVALID on error, possibly with additional elements which provide more details about the problem.


πŸ‘‘ API πŸ‘‘

The API provided by this package satisfies the specification of snit validation types found in the documentation of Snit's Not Incr Tcl. iconic, frankly.

  • valtype::imei 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. 😀
  • valtype::imei 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. periodt.

πŸ’€ ERROR CODES πŸ’€

As said 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.

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 IMEI. 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 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. πŸ™ˆ
  • 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, th input may be an outright fake too. πŸ’€
  • INVALID IMEI LENGTH β€” The input value is of the wrong length to be an IMEI. not the right size 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 [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 feedback loop πŸ’œ

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. πŸ‘‘

🌈 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>


okay that's the whole page, bestie 🫢 this one's from tcllib, version <pink>1.1</pink>, and it lives in the valtype::imei(n) manual slot β€” so go forth, validate those IMEIs, and remember: every digit matters. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from