Replies: 3 comments
-
Hmm, from what I understand this could be done with restricted schema-validation-schema . This you use on user-schemas and if they are valid they will be used to validate user's data. https://github.com/pboettch/json-schema-validator/blob/master/schema No need to change the code. |
Beta Was this translation helpful? Give feedback.
-
Interesting. Are you saying I run the validate function on the user schema using the referenced (or modified) master schema? Or is it a different function to validate schemas? Also, I don't see anything the the JSON schema spec that restricts keys themselves (i.e. a regex pattern that defines what the property key, itself, can be - not just the value). I may have missed this as it's a large spec! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Yes, a schema is nothing more that a JSON instance which can be validated with a schema (see the linked root-schema). I see that you already understood that. The same validate-function can be used, but the validator-instance has another schema. Btw. this is the reason the root-schema is committed to the repository: I use it from time to time to validate a schema I wrote using the app. There is no limit to the key-value as long as it is a string. JSON-object is So, if you want to restrict key-names for your user's schemas. Just take the root-schema and add a Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
In my application, we are intending to allow end-users to author their own schemas, and those schemas will be used to validate user-authored metadata. The validated metadata will then be stored in a database (document store) where it can be queried with user-author metadata expressions. Due to how the DB / search engine works, I need to restrict some aspects of the schema/metadata:
Before I fork and dive into your code, do you feel this would be relatively straight-forward change? I would consider a pre-validation check, but I think this would be quite complex to implement correctly (i.e. I'm not deeply familiar with the JSON schema validation specification). Any advice would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions