-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstructs.js
44 lines (36 loc) · 1.06 KB
/
structs.js
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
import * as s from 'superstruct';
import isUuid from 'is-uuid';
const CATEGORIES = [
'EDUTECH',
'FASHION',
'PET',
'ENVIRONMENT',
'FINTECH',
'TRAVEL',
];
const Uuid = s.define('Uuid', (value) => isUuid.v4(value));
export const CreateUser = s.object({
name: s.size(s.string(), 1, 20),
});
export const PatchUser = s.partial(CreateUser);
export const CreateCompany = s.object({
name: s.size(s.string(), 1, 20),
actualInvest: s.min(s.integer(), 0),
simInvest: s.min(s.integer(), 0),
revenue: s.min(s.integer(), 0),
compareSelectionCount: s.min(s.integer(), 0),
mySelectionCount: s.min(s.integer(), 0),
employeesCount: s.min(s.integer),
description: s.size(s.string(), 1, 500),
category: s.enums(CATEGORIES),
});
export const PatchCompany = s.partial(CreateCompany);
export const CreateInvestment = s.object({
userId: Uuid,
name: s.size(s.string(), 1, 20),
companyID: Uuid,
amount: s.min(s.integer(), 0),
comment: s.size(s.string(), 1, 200),
password: s.size(s.string(), 4, 30),
});
export const PatchInvestment = s.partial(CreateInvestment);