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

zoo validate #134

Open
phiweger opened this issue Apr 21, 2017 · 2 comments
Open

zoo validate #134

phiweger opened this issue Apr 21, 2017 · 2 comments

Comments

@phiweger
Copy link
Owner

...

@phiweger
Copy link
Owner Author

from jsonschema import validate
from zoo.schema import fps, combine

instance = {'_id': '1', 'seq': 'ACTG'}
fragments = ['core', 'derivative']
schema = combine(fps(fragments), additional=False, required=None)
validate(instance, template)  # returns None, all's well

# add a property, which is not one of the allowed properties
instance['foo'] = 'bar'
validate(instance, template)  # throws ValidationError

@phiweger
Copy link
Owner Author

phiweger commented Apr 24, 2017

def is_valid(instance, ):
    '''Validate a hash map against a zoo JSON schemas.

    zoo compose --fp /optional/path core,derivative(allow,recursion?) template.json
    # if it does not find them at top directory will recursively enter subfolders, like node_modules
    # --allow_additonal_fields --required _id,seq,foo,bar
    zoo init --validate path/to/template.json
    '''
...

I think the recursive definition is better than using JSON links/references, bc/ it is more explicit and because the latter are defined/ specified in such a variety of ways, that there seems to be not single best solution but a couple of hacky ones.

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

No branches or pull requests

1 participant