TinKindUS
Which kind of US taxpayer identification number a value turned out to be.
A field labelled just "Tax ID" can hold three different kinds of nine-digit
number: an SSN (a Social Security number — a person), an ITIN (an Individual
Taxpayer Identification Number — a person who cannot get an SSN), or an EIN
(an Employer Identification Number — a business). The label alone does not say
which. CkUS::Tin reads the value's shape and answers with a TinKindUS, so
you can route the value to the right validator, column or mask.
Members
| Member | Meaning |
|---|---|
Invalid |
Not a structurally valid SSN, ITIN or EIN — a missing value included. This is the fallback answer. |
Ssn |
A Social Security number; the shape CkUS::Ssn accepts. |
Itin |
An Individual Taxpayer Identification Number; the shape CkUS::Itin accepts. |
Ein |
An Employer Identification Number; the shape CkUS::Ein accepts. |
Where it is used
Only CkUS uses it: Tin returns a TinKindUS. It tries
Itin first, then Ssn, then Ein, and answers Invalid when none of them
accepts the value — or, with throwIfInvalid: true, throws a CkUSException
that says why. One caution from its docs: a bare nine-digit value that is
structurally a valid SSN is reported as an SSN even when it would also pass as
an EIN — only the dashed '12-3456789' layout is unambiguously an EIN. And it
classifies shape only; it does not tell whether the number was ever issued.
Quick look
use SafeCoder\CommonKit\CkUS;
use SafeCoder\CommonKit\Enums\TinKindUS;
CkUS::Tin('912-70-1234'); // -> TinKindUS::Itin (the area starts with 9)
CkUS::Tin('12-3456789'); // -> TinKindUS::Ein (the dashed 2+7 layout)
CkUS::Tin('123456789'); // -> TinKindUS::Ssn (bare nine digits read as an SSN)
CkUS::Tin('12345'); // -> TinKindUS::Invalid (too short for any of the three)