caolan / forms

An easy way to create, parse and validate forms in node.js
MIT License
1.01k stars 167 forks source link

Form with only boolean fields does not validate successfully #205

Closed net147 closed 4 years ago

net147 commented 6 years ago

If a form has only optional boolean fields, the "other" handler is called instead of the "success" handler when all the boxes are unchecked.

ljharb commented 6 years ago

Thanks, can you provide a test case (code)?

ljharb commented 4 years ago

Specifically, I think this is because of the way browser forms work. If a checkbox is unchecked, nothing is submitted - checkboxes always have to be paired after a hidden input with the "off" value so you can get a reliable signal that the box was unchecked.