Static schema property

49 views
Skip to first unread message

Paul Verhoeven

unread,
Dec 12, 2013, 8:13:41 AM12/12/13
to mongoo...@googlegroups.com
I've got incoming JSON something like:
{ "foo": "bar", "other": 1, "another": "A" }
Now i know for a fact that "foo" always need to be "bar". I found two solutions for making that happen in my schema: Using an enum or writing a validator which both seem overkill for something like sting comparison. I was hoping i could do something simple like:
{ "foo": "bar", "other": Number, "another": String }
or something like this:
{ "foo": { type: String, value: "bar" }, "other": Number, "another": String }
Can't seem to find something like that so i was wondering if i am correct in my findings and not overseeing something so that i can continue and to choose between using an enum or a validator.

Reply all
Reply to author
Forward
0 new messages