valtype::usnpi(3tcl)

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

πŸ’– 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 the value and 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 the value. 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 (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