valtype::usnpi(n)

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

✨ valtype::usnpi ✨

okay bestie, gather round, we're talking about valtype::usnpi(n) β€” a page from the Validation types corner of the manual, shipped with tcllib version 1.1. it's giving niche-but-essential, fr fr πŸ’…


πŸŽ€ NAME πŸŽ€

valtype::usnpi β€” validation for USNPI. yes queen, that's the whole name, short and iconic 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

package require Tcl 8.5 9

package require snit 2

package require valtype::common

package require valtype::luhn

package require valtype::usnpi ?1.1?

valtype::usnpi validate value

valtype::usnpi checkdigit value

look at all those package requires. it's a whole little ecosystem, and this package is the main character πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so this package implements a snit validation type for an USNPI. periodt.

now, what even is a validation type? bestie, it's an object you can use to validate Tcl values of a particular kind. classic 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 data type ✨

every validation type has a validate method, and that's the one doing the actual validating. it must take a single argument β€” the value to be validated. and here's the vibe check: it must do nothing if the value is valid, but throw an error if the value is invalid:

valtype::usnpi validate .... ;# Does nothing
valtype::usnpi validate .... ;# Throws an error (bad US National Provider Identifier (US-NPI) number).

on success, the validate method will always return the validated value. on error, it throws the -errorcode INVALID, possibly with extra elements attached that give you more deets about what went wrong. no cap 🫢


🌈 API 🌈

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

  • valtype::usnpi validate value β€” this method validates the value and returns it, possibly in a canonical form, if it passes. if it does not pass? error thrown, sorry babe 😭
  • valtype::usnpi checkdigit value β€” this method computes a check digit for the value. before doing that, it validates it β€” except for a checkdigit. so if the value doesn't pass validation, no check digit gets calculated and an error is thrown instead. it's giving "no digit for you until you behave" πŸ™ˆ

πŸ’€ ERROR CODES πŸ’€

like the package description said: the errors thrown by this package's commands in response to input validation failures use the -errorcode INVALID so they can tell themselves apart from package internal errors. iconic boundary-setting, honestly.

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

  • INVALID USNPI 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 USNPI. wrong characters, bestie, we can't work with that πŸ’…
  • INVALID USNPI CHECK-DIGIT β€” the check digit of the input value is wrong. this usually signals a data-entry error, with digits transposed, forgotten, etc. and of course, th input may be an outright fake too. 😳 lowkey the drama we live for
  • INVALID USNPI LENGTH β€” the input value is of the wrong length to be an USNPI. too short, too long, not the vibe πŸ“

🫢 BUGS, IDEAS, FEEDBACK 🫢

ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's fine, we're all growing. 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 want the glow-up ideas, 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. yes, that specific button. go get it πŸŽ€


⭐ KEYWORDS ⭐

Checking, NPI, National Provider Identifier, Testing, Type checking, US-NPI, Validation, Value checking, isA, medicare

iykyk πŸ”₯


πŸ‘‘ CATEGORY πŸ‘‘

Validation, Type checking


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


and that's the whole page bestie!! this came out of tcllib, version 1.1, and it lives over in the valtype::usnpi(n) manual slot. go validate something, you're doing amazing πŸ¦‹πŸ’œβœ¨

πŸ“¦ where this page comes from