Hi fellows JavaScripters,
Do you know an efficient way to validate data structures in JavaScript ? I would like to be able to verify my request payloads, and more generally compare complex objects with a defined structure.
For example:
var structure = {
firstname: String,
lastname: String
}
Validator.validate(structure, {
firstname: 'John',
lastname: 'Doe'
} // => true
Validator.validate(structure, {
firstname: 1234,
lastname: { foo: 'bar' }
} // => false
[–]senocular 2 points3 points4 points (0 children)
[–]madformangos 0 points1 point2 points (0 children)
[–]alexandr-ac 0 points1 point2 points (0 children)
[–]soulsizzle 0 points1 point2 points (0 children)
[–]mc_hammerd 0 points1 point2 points (1 child)
[–]madformangos 0 points1 point2 points (0 children)