how to sanitize request body in node js


export const registrationSchema = {
    "email": {
        notEmpty: true,
        isEmail: {
            errorMessage: "Invalid Email"
        }
    },
    "password": {
        notEmpty: true,
        isLength: {
            options: [{min: 12}],
            errorMessage: "Must be at least 12 characters"
        },
        matches: {
            options: ["(?=.*[a-zA-Z])(?=.*[0-9]+).*", "g"],
            errorMessage: "Password must be alphanumeric."
        },
        errorMessage: "Invalid password"
    },
    "firstName": {
        notEmpty: false,
        isLength: {
            options: [{max: 200}],
            errorMessage: "The first name must be under 200 characters"
        },
        matches: {
            options: ["^[a-z ,.'-]+$", "i"],
            errorMessage: "The first name can only contain letters and the characters (,.'-)"
        }
    },
    "lastName": {
        notEmpty: false,
        isLength: {
            options: [{max: 200}],
            errorMessage: "The last name must be under 200 characters"
        },
        matches: {
            options: ["^[a-z ,.'-]+$", "i"],
            errorMessage: "The last name can only contain letters and the characters (,.'-)"
        }
    }
};

www.codegrepper.com
www.stackoverflow.com

how to push multiple data to different parents in a single request in firebase


var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
// Generate a new push ID for the new post
var newPostRef = ref.child("posts").push();
var newPostKey = newPostRef.key();
// Create the data we want to update
var updatedUserData = {};
updatedUserData["user/posts/" + newPostKey] = true;
updatedUserData["posts/" + newPostKey] = {
title: "New Post",
content: "Here is my new post!"
};
// Do a deep-path update
ref.update(updatedUserData, function(error) {
if (error) {
console.log("Error updating data:", error);
}
});

www.codegrepper.com
www.stackoverflow.com