angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

There is no schema to validate a Form Schema against

Open quietlyconfident opened this issue 10 years ago • 5 comments

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:

  1. Create a form directly from a JSON schema, and
  2. 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:

  1. It would prevent typo issues and all of the other sorts of errors that data validation protects against.
  2. The schema could help enable compatibility with other projects, for example:

quietlyconfident avatar Oct 05 '14 21:10 quietlyconfident

I am unable to assign labels but, in my view, this should be labeled enhancement.

quietlyconfident avatar Oct 05 '14 21:10 quietlyconfident

That's a good idea, and would make error messages much clearer!

fiddur avatar Oct 06 '14 07:10 fiddur

Architecture

quietlyconfident avatar Oct 06 '14 18:10 quietlyconfident

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 avatar Oct 16 '14 14:10 rhalff

@rhalff as of 1.0.0-alpha.2 $ref is supported as a preprocessing step.

Anthropic avatar Feb 19 '17 13:02 Anthropic