how to sanitize request body in node js

Solutions on MaxInterview for how to sanitize request body in node js by the best coders in the world

showing results for - "how to sanitize request body in node js"
Lisa
03 Aug 2019
1export const registrationSchema = {
2    "email": {
3        notEmpty: true,
4        isEmail: {
5            errorMessage: "Invalid Email"
6        }
7    },
8    "password": {
9        notEmpty: true,
10        isLength: {
11            options: [{min: 12}],
12            errorMessage: "Must be at least 12 characters"
13        },
14        matches: {
15            options: ["(?=.*[a-zA-Z])(?=.*[0-9]+).*", "g"],
16            errorMessage: "Password must be alphanumeric."
17        },
18        errorMessage: "Invalid password"
19    },
20    "firstName": {
21        notEmpty: false,
22        isLength: {
23            options: [{max: 200}],
24            errorMessage: "The first name must be under 200 characters"
25        },
26        matches: {
27            options: ["^[a-z ,.'-]+$", "i"],
28            errorMessage: "The first name can only contain letters and the characters (,.'-)"
29        }
30    },
31    "lastName": {
32        notEmpty: false,
33        isLength: {
34            options: [{max: 200}],
35            errorMessage: "The last name must be under 200 characters"
36        },
37        matches: {
38            options: ["^[a-z ,.'-]+$", "i"],
39            errorMessage: "The last name can only contain letters and the characters (,.'-)"
40        }
41    }
42};
43