-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.schema.js
More file actions
65 lines (59 loc) · 1.54 KB
/
Copy pathuser.schema.js
File metadata and controls
65 lines (59 loc) · 1.54 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import * as Yup from 'yup'
const minLength = {
name: 2,
city: 1,
country: 2
};
const maxLength = {
name: 20,
city: 30,
country: 30,
email: 100
}
export const getUser = {
schema: {
params: {
yupSchema: Yup.object().shape({
id: Yup.number().required(),
}),
}
},
}
export const addUser = {
schema: {
body: {
yupSchema: Yup.object().shape({
name: Yup.string().min(minLength.name).max(maxLength.name).required(),
email: Yup.string().email().max(maxLength.email),
city: Yup.string().min(minLength.city).max(maxLength.city),
country: Yup.string().min(minLength.country).max(maxLength.country),
}),
}
},
};
export const updateUser = {
schema: {
params: {
yupSchema: Yup.object().shape({
id: Yup.number().required(),
}),
},
body: {
yupSchema: Yup.object().shape({
name: Yup.string().min(minLength.name).max(maxLength.name).required(),
email: Yup.string().email().max(maxLength.email),
city: Yup.string().min(minLength.city).max(maxLength.city),
country: Yup.string().min(minLength.country).max(maxLength.country),
}),
}
},
}
export const deleteUser = {
schema: {
params: {
yupSchema: Yup.object().shape({
id: Yup.number().required(),
}),
},
},
}