UNPKG

534 BJavaScriptView Raw
1var Valida = require('..');
2
3
4var schema = {
5 name: [
6 { sanitizer: Valida.Sanitizer.trim, groups: ['simple'] },
7 { sanitizer: Valida.Sanitizer.trim, chars: '\\[\\]', groups: ['chars'] }
8 ]
9};
10
11
12var person = { name: ' Eduardo Nunes ' };
13
14
15Valida.process(person, schema, function(err, ctx) {
16 // jshint unused:false
17 console.log('simple', person);
18}, 'simple');
19
20
21person.name = '[Eduardo Nunes]';
22
23
24Valida.process(person, schema, function(err, ctx) {
25 // jshint unused:false
26 console.log('chars', person);
27}, 'chars');