Closed
Description
I've included a boolean field in my schema form demo. I would like it to be a "Terms and Conditions" checkbox, where the user is required to check the box before continuing. Making the field a required field does nothing, I assume because false is a value. In order to gain the functionality to require the checkbox to be checked, I added a function to the $validators object. This worked in that the form cannot be processed without the checkbox being checked. However, the user is given no message below the checkbox itself, even though I included a validation message.
Have I missed something? I'd love for the checkbox to get the same validation cues as input fields.
Activity
TimCorey commentedon Jul 13, 2016
After further testing, it seems as though the validation message will fire if I check the box and then uncheck it. It will also show the proper error. This still doesn't happen on submit. That is where I need it to happen.
Just for further clarity, I'm not giving the checkbox an initial value, which means it defaults to false (which is what I want).
Anthropic commentedon Jul 17, 2016
@TimCorey have you tried using validateOnRender, that would show the error immediately? Failing that can you hide the submit buttons until the checkbox is checked?
Anthropic commentedon Jul 17, 2016
I do see the issue though and agree it is a bug worth addressing.
Anthropic commentedon Apr 15, 2017
@TimCorey I am closing this because technically the attribute you want is
{ const: true }
as part of the schema, this isn't supported in tv4, but making ajv or djv available to validate with is already covered in other issues.Const is part of json-schema v6 json-schema-org/json-schema-spec#58