valtype::usnpi(3tcl)
π valtype::usnpi β the manual, but make it make sense π
okay bestie, welcome to valtype::usnpi(3tcl), a page from the Tcllib manual set. it's the validation-type page for USNPI (that's a US National Provider Identifier, the medicare number thing π©Ί). it's short, it's sweet, it slaps. let's go β¨
πΈ NAME πΈ
valtype::usnpi β validation for USNPI π
β¨ 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
so yeah, she needs Tcl 8.5 or 9, plus snit 2, plus valtype::common and valtype::luhn as her little support squad. the ?1.1? on the valtype::usnpi require means that version is optional-ish, iykyk. π«Ά
π DESCRIPTION π
this package implements a snit validation type for a USNPI. no cap.
so like, what even is a validation type? it's an object that checks whether a Tcl value is the right kind of thing. for example, snit::integer β a validation type defined by the snit package β is used to verify that a Tcl value is an integer. same energy, different number. π«
every validation type has a validate method, and that's the whole main character of the show. it takes one single argument: the value you want validated. and it has rules, bestie:
- if the value is valid β it does nothing. literally nothing. silence. peace. ποΈ
- if the value is invalid β it throws an error. dramatic, but necessary.
here's the vibe in code:
valtype::usnpi validate .... ;# Does nothing
valtype::usnpi validate .... ;# Throws an error (bad US National Provider Identifier (US-NPI) number).
on success the validate method always returns the validated value. on failure it throws with the errorcode INVALID, and it may attach extra elements giving you more deets about what went wrong. π΅οΈβοΈ
π API π
the API this package gives you fully satisfies the spec for snit validation types, the one in the documentation of Snit's Not Incr Tcl. periodt.
valtype::usnpi validate valueβ checks thevalueand hands it back if it passes, possibly in a canonical form (glow up moment β¨). if it doesn't pass, an error gets thrown, no discussion.valtype::usnpi checkdigit valueβ computes a check digit for thevalue. but first, she validates it β except for the check digit itself, obviously, because how are you gonna validate a thing you haven't computed yet π. if the value flops validation, no check digit for you, just an error. sorry babe.
π¨ ERROR CODES π¨
like the package description said, when input validation fails, the errors thrown by these commands use the errorcode INVALID, which is how they distinguish themselves from boring package-internal errors. iconic.
but to give you the full tea about why validation failed, the -errorCode actually goes beyond just that. first it contains a code telling you the type itself β here, that's USNPI. then it's followed by values describing the reason for the failure. the complete set of -errorCodes this package can throw:
INVALID USNPI CHARACTERβ your input had one or more bad characters, i.e. characters that must not occur in the input for it to be a USNPI. πINVALID USNPI CHECK-DIGITβ the check digit of the input value is wrong. this usually means a data-entry error, like digits transposed, forgotten, whatever. and of course, the input might just be an outright fake too. πINVALID USNPI LENGTHβ the input value is the wrong length to be a USNPI. too long, too short, just not it.
π BUGS, IDEAS, FEEDBACK π
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. please report those in the category valtype of the Tcllib Trackers: [http://core.tcl.tk/tcllib/reportlist]. and please also report any ideas for enhancements you have for either the package and/or the documentation. we love a glow-up suggestion π«Ά
when you propose code changes, please provide unified diffs, i.e. the output of diff -u. that's the language we speak.
also note: attachments are strongly preferred over inlined patches. how do you attach? go to the Edit form of the ticket right after it's created, then use the left-most button in the secondary navigation bar. yes, that button. that one. π
π KEYWORDS π
Checking, NPI, National Provider Identifier, Testing, Type checking, US-NPI, Validation, Value checking, isA, medicare
ποΈ CATEGORY ποΈ
Validation, Type checking
Β©οΈ COPYRIGHT Β©οΈ
Copyright (c) 2011 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page, bestie π this was valtype::usnpi(3tcl), version 1.1, shipped with tcllib. go forth and validate those NPIs, you absolute legend. slay, and remember: no cap, only check digits. β¨π¦π
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2011 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms