-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvalidation.ts
47 lines (43 loc) · 1.45 KB
/
validation.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { isValidStringProperty } from "../validation/string";
export function validateIncludeClassNames(classNames?: string[]) {
if (Array.isArray(classNames)) {
let errors: any[] = [];
classNames.forEach(className => {
if (!isValidStringProperty(className)) {
errors.push("string className invalid - set with .withIncludeClassNames(...classNames)")
}
});
return errors;
}
if (classNames !== null && classNames !== undefined) {
return ["strings classNames invalid - set with .withIncludeClassNames(...classNames)"];
}
return [];
}
export function validateExcludeClassNames(classNames?: string[]) {
if (Array.isArray(classNames)) {
let errors: any[] = [];
classNames.forEach(className => {
if (!isValidStringProperty(className)) {
errors.push("string className invalid - set with .withExcludeClassNames(...classNames)")
}
});
return errors;
}
if (classNames !== null && classNames !== undefined) {
return ["strings classNames invalid - set with .withExcludeClassNames(...classNames)"];
}
return [];
}
export function validateBackend(backend?: string) {
if (!isValidStringProperty(backend)) {
return ["string backend must set - set with .withBackend(backend)"];
}
return [];
}
export function validateBackupId(backupId?: string) {
if (!isValidStringProperty(backupId)) {
return ["string backupId must be set - set with .withBackupId(backupId)"];
}
return [];
}