TextField is not treating space as empty value when performing Required check
Describe the bug The TextField component does not seems to be treating space character " " as empty value, which was the case in previous version ("formiojs": "4.13.10")
Version/Branch version: 5.0.1
To Reproduce Steps to reproduce the behavior:
- Create empty form
- Add TextField component
- Set TextField -> Validation -> Required to checked
- Add Button component
- Set Button -> Disable on Form Invalid to checked
- Open the form
- Enter space in the TextField
Expected behavior: Required area is displayed, and the Submit button remain disabled Actual behavior: the Submit button is enabled
minimum form components for replication
"components": [ { "input": true, "tableView": true, "label": "Text Field", "type": "textfield", "key": "textField", "validate": { "required": true } }, { "input": true, "showValidations": false, "tableView": false, "label": "Submit", "type": "button", "disableOnInvalid": true, "key": "submit", "saveOnEnter": false } ],
Screenshots now:
previous:
Additional context I believe this to be due to the switch from component defined validation in previous version which include trim to input value https://github.com/formio/formio.js/blob/v4.13.1/src/validator/rules/Required.js#L9 https://github.com/formio/formio.js/blob/v4.13.1/src/components/textfield/TextField.js#L165
to centralized validation definition which does not perform trim before the validation
https://github.com/formio/core/blob/e21741ae1c927cb43528cb1de44e08e85d2ea843/src/process/validation/rules/validateRequired.ts#L50