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

Report more specific errors in module group validation #11

Open
serin-delaunay opened this issue Sep 10, 2017 · 0 comments
Open

Report more specific errors in module group validation #11

serin-delaunay opened this issue Sep 10, 2017 · 0 comments

Comments

@serin-delaunay
Copy link
Contributor

serin-delaunay commented Sep 10, 2017

Currently, if a noise module doesn't conform to a module schema, the reported error will be that it failed a oneOf schema. This build has an example:

  File "C:\Python36\lib\site-packages\jsonschema\validators.py", line 130, in validate
jsonschema.exceptions.ValidationError: {'type': 'Bitmap', 'Filename': 'zigzag.png', 'Region': [[-1, -1], [2, 2]], 'DefaultValue': 0} is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['modules']['additionalProperties']:
    {'oneOf': [{'$ref': '#/definitions/abs'},
               {'$ref': '#/definitions/add'},
               {'$ref': '#/definitions/billow'},
               {'$ref': '#/definitions/bitmap'},
               {'$ref': '#/definitions/blend'},
               {'$ref': '#/definitions/checkerboard'},
               {'$ref': '#/definitions/clamp'},
               {'$ref': '#/definitions/const'},
               {'$ref': '#/definitions/corner_combiner_base'},
               {'$ref': '#/definitions/curve'},
               {'$ref': '#/definitions/cylinders'},
               {'$ref': '#/definitions/displace'},
               {'$ref': '#/definitions/exponent'},
               {'$ref': '#/definitions/exp'},
               {'$ref': '#/definitions/forward'},
               {'$ref': '#/definitions/gradient_x'},
               {'$ref': '#/definitions/gradient_y'},
               {'$ref': '#/definitions/gradient_z'},
               {'$ref': '#/definitions/invert'},
               {'$ref': '#/definitions/max'},
               {'$ref': '#/definitions/min'},
               {'$ref': '#/definitions/multiply'},
               {'$ref': '#/definitions/norm_lp_q'},
               {'$ref': '#/definitions/perlin'},
               {'$ref': '#/definitions/power'},
               {'$ref': '#/definitions/pow'},
               {'$ref': '#/definitions/quadrant_selector'},
               {'$ref': '#/definitions/ridged_multi'},
               {'$ref': '#/definitions/rotate_point'},
               {'$ref': '#/definitions/scale_bias'},
               {'$ref': '#/definitions/scale_point'},
               {'$ref': '#/definitions/select'},
               {'$ref': '#/definitions/spheres'},
               {'$ref': '#/definitions/terrace'},
               {'$ref': '#/definitions/translate_point'},
               {'$ref': '#/definitions/turbulence'},
               {'$ref': '#/definitions/voronoi'}]}
On instance['modules']['zigzag']:
    {'DefaultValue': 0,
     'Filename': 'zigzag.png',
     'Region': [[-1, -1], [2, 2]],
     'type': 'Bitmap'}

This error is not very helpful, because while it shows the part of the JSON document causing the error (a Bitmap module, it doesn't show the Bitmap module schema and the reason this module didn't conform to it. The user must look up the Bitmap schema themself, and find that the problem is Wangscape/Wangscape#197.

This is an instance of python-jsonschema/jsonschema#169, and the recommended solution is to use jsonschema's best_match/context features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants