Looking for a library that can help me describe data structures. For instance, imagine I have an application that receives data via XHR and checks the response JSON.
Validating complex responses with imperative code can be quite challenging. I'd like to be able to declaratively describe these models/structures/DTOs and then use them in the following way:
var Animal = Model.define({
head: Head,
limbs: List(Leg, {min: 0, max: 4}),
...
});
try {
var animal = Animal.load(anyJsonStringOrObject);
} catch (e) {
console.log('Error loading model');
}