-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathaccount.validator.js
More file actions
44 lines (43 loc) · 1.83 KB
/
account.validator.js
File metadata and controls
44 lines (43 loc) · 1.83 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
"use strict";
const VALIDATOR = require("./validator.helper");
const Constants = require("../../constants/general.constant");
module.exports = {
newAccountValidator: [
VALIDATOR.stringValidator("body", "firstName", false),
VALIDATOR.stringValidator("body", "lastName", false),
VALIDATOR.alphaArrayValidator("body", "pronoun", false),
VALIDATOR.stringValidator("body", "gender", false),
VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX),
VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", false),
VALIDATOR.stringValidator("body", "gender", false),
VALIDATOR.passwordValidator("body", "password", false),
VALIDATOR.jwtValidator(
"header",
"token",
process.env.JWT_CONFIRM_ACC_SECRET,
true
),
VALIDATOR.ageValidator("body", "age", false),
VALIDATOR.phoneNumberValidator("body", "phoneNumber", true)
],
updateAccountValidator: [
VALIDATOR.stringValidator("body", "firstName", true),
VALIDATOR.stringValidator("body", "lastName", true),
VALIDATOR.alphaArrayValidator("body", "pronoun", true),
VALIDATOR.stringValidator("body", "gender", true),
VALIDATOR.regexValidator("body", "email", true, Constants.EMAIL_REGEX),
VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", true),
VALIDATOR.stringValidator("body", "gender", true),
VALIDATOR.ageValidator("body", "age", true),
VALIDATOR.phoneNumberValidator("body", "phoneNumber", true)
],
inviteAccountValidator: [
VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX),
VALIDATOR.enumValidator(
"body",
"accountType",
Constants.EXTENDED_USER_TYPES,
false
)
]
};