Skip to content

Misinterpretation of "required" for boolean properties #928

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

Closed
tommywalsh opened this issue Sep 21, 2017 · 1 comment
Closed

Misinterpretation of "required" for boolean properties #928

tommywalsh opened this issue Sep 21, 2017 · 1 comment

Comments

@tommywalsh
Copy link

The JSON Schema spec says this about the "required" keyword:

An object instance is valid against this keyword if every item in the array is the name of a property in the instance.

In other words, marking a property as "required" is supposed to mean "This property must not be omitted from the object instance".

See http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.17

For boolean properties, I believe this keyword is being misinterpreted. It appears that angular-schema-form is interpreting "required" to mean "The user must check this box". Or, in other words "required" is being interpreted to mean "This property must have the value 'true'".

This can be seen on the schemaform demo site: http://schemaform.io/examples/bootstrap-example.html

  1. Select the "Kitchen Sink" option
  2. In the schema section, add "soul" to the "required" array.
  3. Go to the "generated form" section, and uncheck the "Terms of Service" checkbox.
  4. Click the "Do It" button

You will see "Form is not valid", and you will see that the "Terms of Service" widget gets a red "required" warning.

It seems as if angular-schema-form is imposing its own meaning onto the "required" keyword for boolean properties. This seemingly makes it impossible to define a schema that says "the object instance must contain this field, but it can be either true or false".

@Anthropic
Copy link
Member

I believe this is a duplicate of #857 which has been resolved in the latest alpha. I'm hoping to release another in the next few weeks.

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