change according to connection from frontend
This commit is contained in:
parent
2609ecc1bf
commit
e3db523a0e
36 changed files with 611 additions and 173 deletions
18
src/helpers/typeTester.ts
Normal file
18
src/helpers/typeTester.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { PlanTimeDefinition } from "../viewmodel/admin/unit/inspection/inspectionPlan.models";
|
||||
|
||||
export default abstract class TypeTester {
|
||||
static testPlanTimeDefinition(val: string, key: string = "", throwErr: boolean = false): PlanTimeDefinition | null {
|
||||
if (/^(\d+-(d|m|y)|\d+\/(\d+|\*))$/.test(val)) {
|
||||
return val as PlanTimeDefinition;
|
||||
} else if (throwErr) {
|
||||
throw Error(
|
||||
[
|
||||
key,
|
||||
"provided String does not match PlanTimeDefinition Format: ${number}-${'d'|'m'|'y'} or ${number}/${number|'*'}",
|
||||
].join(": ")
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue