-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidations.js
More file actions
20 lines (17 loc) · 850 Bytes
/
validations.js
File metadata and controls
20 lines (17 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { body } from "express-validator";
export const registerValidation = [
body("email", 'Incorrect email format').isEmail(),
body("password", 'Password must be at least 5 symbols').isLength({ min: 5 }),
body("fullName", 'Write down your name (at least 3 symbols)').isLength({ min: 3 }),
body("avatarUrl",'Incorrect image URL').optional().isURL(),
];
export const loginValidation = [
body("email", 'Incorrect email format').isEmail(),
body("password", 'Password must be at least 5 symbols').isLength({ min: 5 }),
];
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", 'Incorrect tag format').optional().isString(),
body("imageUrl",'Incorrect image URL').optional().isString(),
];