UNPKG

523 BJavaScriptView Raw
1var Valida = require('..');
2
3
4var schema = {
5 birthday: [
6 { sanitizer: Valida.Sanitizer.toDate }
7 ]
8};
9
10
11var person = { birthday: 'Tue Oct 08 2013 19:09:56 GMT-0300 (BRT)' };
12
13
14Valida.process(person, schema, function(err, ctx) {
15 // jshint unused:false
16 console.log(person, Object.prototype.toString.call(person.birthday));
17});
18
19
20person.birthday = new Date();
21
22
23Valida.process(person, schema, function(err, ctx) {
24 // jshint unused:false
25 console.log(person, Object.prototype.toString.call(person.birthday));
26});