Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NonDictModel class #379

Closed
wants to merge 1 commit into from

Conversation

mlyundin
Copy link

Please review. I have found that this is useful using schematics for validation of json data. According to json specification we can have not only 'dict' on top level.

@bintoro
Copy link
Member

bintoro commented Jan 26, 2016

What specification? The JSON specification certainly allows objects at the top level.

I can't help thinking there must a better solution to the problem you're facing. While this isn't mergeable as such, we can look into the actual issue if you can provide more information.

@mlyundin
Copy link
Author

From http://www.json.org/
In JSON, they take on these forms:
An object is an unordered set of name/value pairs.
An array is an ordered collection of values.

In my work I have faced with REST responses with json data as array on top level

@bintoro
Copy link
Member

bintoro commented Jan 26, 2016

If you only wish to validate, say, a list of integers, you can simply use a standalone field:

>>> field = ListType(IntType)
>>> field.validate([1, 2, "3", 4])
[1, 2, 3, 4]

You don't need a containing model to do this.

@bintoro bintoro closed this Jan 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants