-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidations.js
More file actions
28 lines (25 loc) · 893 Bytes
/
Copy pathvalidations.js
File metadata and controls
28 lines (25 loc) · 893 Bytes
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
import { body } from "express-validator";
export const loginValidation = [
body("email", "Wrong type of email").isEmail(),
body("password", "Password must be at least five symbols").isLength({
min: 5,
}),
];
export const registerValidation = [
body("email", "Wrong type of email").isEmail(),
body("password", "Password must be at least five symbols").isLength({
min: 5,
}),
body("fullName", "Name must be at least 3 symbols").isLength({ min: 3 }),
body("avatarUrl", "Wrong url, try again").optional().isURL(),
];
export const postCreateValidation = [
body("title", "Enter title of the post").isLength({ min: 3 }).isString(),
body("text", "Enter text of the post")
.isLength({
min: 10,
})
.isString(),
body("tags", "Wrong type of tags (enter the array)").optional().isArray(),
body("imageUrl", "Wrong url, try again").optional().isURL(),
];