-
Notifications
You must be signed in to change notification settings - Fork 54
/
clia.ts
29 lines (27 loc) · 1023 Bytes
/
clia.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { states, noCLIAValidationStates } from "../../config/constants";
export function stateRequiresCLIANumberValidation(
state: keyof typeof states
): boolean {
return !noCLIAValidationStates.includes(state);
}
export function isValidCLIANumber(input: string, state: string): boolean {
let cliaNumberValidator;
if (state === "WA") {
cliaNumberValidator = /^\d{2}[DZ]\d{7}$/;
} else if (state === "CA") {
cliaNumberValidator = /^\w{2}[D]\w{1}\d{6}$/;
} else if (state === "NM" && input.substring(0, 3) === "32Z") {
cliaNumberValidator = /^32Z\d{7}$/;
} else if (state === "VT" && input.substring(0, 3) === "47Z") {
cliaNumberValidator = /^47Z\d{7}$/;
} else if (state === "IL" && input === "14DISBE123") {
return true;
} else if (state === "WY" && input === "12Z3456789") {
return true;
} else if (input.substring(0, 3) === "DOD") {
cliaNumberValidator = /^DOD\d{7}$/;
} else {
cliaNumberValidator = /^\d{2}D\d{7}$/;
}
return cliaNumberValidator.test(input);
}