kriszyp/json-schema — Issue #30: Arrays and Dates validate as objects
Author: secoif
Created: 2011-10-12 12:26:10+00:00
State: open

a schema containing a property:

thing : { type : "object", "required" : true }

will validate true for:

thing: []
thing: new Date()

This is a bit annoying and plain wrong (though the blame probably lies on JS itself). Perhaps there's some RPC-aligned reason for arrays and dates to be objects?

May I propose you use (or align with) sugarjs (http://sugarjs.com/api) to perform your "is type" validations? It'd be good if the JS community would form some kind of consensus about what is and isn't an object, and I believe sugarjs does a good job of this.

I'll put together a pull request if you wouldn't mind adding an (awesome) dependency.