mass-assign-filter Helper Module
A helper module for Node.js that sanitize objects based in the white list array.
Install
npm install --save mass-assign-filter
Test (Uses Mocha globaly)
npm test
Example 1:
const massAssign = ; // massAssign(object, array[, isWhiteList = true]); const person = name: "Roberto" age: 22 admin: true ; // Using black list const blackList = 'admin'; console; // => { name: "Roberto", age: 22 } // Using white list const whiteList = 'name' 'age'; console; // => { name: "Roberto", age: 22 }
Example 2 (White List):
// With White List const mongoose = ; const Person = mongoose; const massAssign = ; module { return /** * ... **/ { const whiteList = 'name' 'age'; Person; } ; };
Example 3 (Black List):
// With Black List const mongoose = ; const Person = mongoose; const massAssign = ; module { return /** * ... **/ { const blackList = 'admin'; Person; } ; };