-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathutils.ts
29 lines (26 loc) · 862 Bytes
/
utils.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 { isInvalidName } from 'applications/operationalStudies/utils';
import {
SMALL_TEXT_AREA_MAX_LENGTH,
TEXT_AREA_MAX_LENGTH,
TEXT_INPUT_MAX_LENGTH,
isInvalidString,
} from 'utils/strings';
import type { ProjectForm } from './components/AddOrEditProjectModal';
const checkProjectFields = (
project: ProjectForm
): {
name: boolean;
objectives: boolean;
description: boolean;
funders: boolean;
budget: boolean;
} => ({
name: isInvalidName(project.name),
objectives: isInvalidString(TEXT_AREA_MAX_LENGTH, project.objectives),
description: isInvalidString(SMALL_TEXT_AREA_MAX_LENGTH, project.description),
funders: isInvalidString(TEXT_INPUT_MAX_LENGTH, project.funders),
budget:
(project.budget ?? 0) > 2147483647 ||
(!Number.isInteger(project.budget) && project.budget !== null),
});
export default checkProjectFields;