angular-schema-form
angular-schema-form copied to clipboard
There is no schema to validate a Form Schema against
Brief
There should be a schema that defines what a valid angular-schema-form schema is, and could be used to validate an angular-schema-form schema.
Background
From the README, Angular Schema Form can:
- Create a form directly from a JSON schema, and
- Validate form fields against the same JSON schema.
In other words, to use Angular-Schema-Form, you create a Form Definition which is a JSON Schema and defines the layout of the form as well as the validation requirements for the data. Angular-Schema-Form translates this into an HTML form and the data can come back and be validated against the Form Definition. Great! So far, so good.
But, how do you know if your Form Definition is valid? In other words, how to know that the Form Definition doesn't request unsupported field types, i.e. attempts to use an unsupported add-on, etc? Or perhaps if the Form Definition is just malformd.
To do so, it would be nice if there were another schema against which the Form Definition could be validated This would serve two purposes:
- It would prevent typo issues and all of the other sorts of errors that data validation protects against.
- The schema could help enable compatibility with other projects, for example:
I am unable to assign labels but, in my view, this should be labeled enhancement.
That's a good idea, and would make error messages much clearer!
Hi, I like this idea and tried to made an attempt in creating such a thing:
https://github.com/rhalff/json-form-form-schema-validator
The current schema is overhere: https://github.com/rhalff/json-form-form-schema-validator/blob/master/schema-form.json
I'm not sure it will make error messages much cleared though, because the .form
array can contain many different types.
The error report will then show it did not match any of the possible structures.
e.g. It will not tell you whether a field looks like a select and there was a typo somewhere. The select would just not match and the next definition is tried.
I was hopeing I could use this schema to automatically generate a form to define a form, but it's still far off, angular-schema-form would also need to understand "$ref" which it currently doesn't.
@rhalff as of 1.0.0-alpha.2 $ref is supported as a preprocessing step.