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