Skip to content

Instantly share code, notes, and snippets.

@tjstebbing
Created July 27, 2014 06:41
Show Gist options
  • Select an option

  • Save tjstebbing/6636392cd985c1476087 to your computer and use it in GitHub Desktop.

Select an option

Save tjstebbing/6636392cd985c1476087 to your computer and use it in GitHub Desktop.
var data = {
id : "11234141231231245113",
name "Choclate Cake",
tags : [
{id : "123123568674635735", label : "Baking"},
{id : "347457457745745743", label : "Chocolate"}
]
}
var schema = s.Object({
id : s.ObjectID({doc : "ID of the object"}),
name : s.String({min:3, max:256, doc : "Users preferred name"}),
tags : s.Array({opt : true}, [s.Object({
id : s.ObjectID(),
label : s.String({opt : true})
})]),
extras : s.Object({opt:true, strict:false}, {})
});
s.validate(schema, data);
s.addValidators({"ObjectID" : ObjectIDValidator});
s = {
parsers : {
Int : IntParser,
Str : StrParser,
Date : DateParser,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment