jpmckinney / validictory

🎓 deprecated general purpose python data validator
Other
240 stars 57 forks source link

Schema for non "object" types #29

Closed alfredodeza closed 12 years ago

alfredodeza commented 12 years ago

I am trying to create a schema that will validate something like:

{"string": 1}

Or:

{1: "string"}

But I could not find any examples on how to achieve that, since "string" is just accepting any kind of string really, but it needs to make sure it has an integer as a value. I am sure there are other combinations that I am not looking into but again, I could not find anything in the docs regarding this specific scenario.

Is this actually possible?

jamesturk commented 12 years ago

sorry, {1: "string"} isn't valid JSON so no it cannot be validated

On Tue, May 29, 2012 at 5:02 PM, Alfredo Deza < reply@reply.github.com

wrote:

I am trying to create a schema that will validate something like:

{"string": 1}

Or:

{1: "string"}

But I could not find any examples on how to achieve that, since "string" is just accepting any kind of string really, but it needs to make sure it has an integer as a value. I am sure there are other combinations that I am not looking into but again, I could not find anything in the docs regarding this specific scenario.

Is this actually possible?


Reply to this email directly or view it on GitHub: https://github.com/sunlightlabs/validictory/issues/29

alfredodeza commented 12 years ago

Probably a bad example :)

But you didn't addressed it the other way around:

{"string": 1}

Which is perfectly valid JSON. Could you please let me know if there is any way this can be accomplished with Validictory as I couldn't find any examples on how to achieve this reading the documentation?