-
-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Problem
Auto injecting a NotEmpty validator is very possibly not wanted in some situations but completely unavoidable if you mark an input as required.
If you are translating your error messages, the auto-injected validator will not receive a translator instance and will yield the default (probably english) error message.
Iterating over and manipulating the validator inside Input relies on concrete methods in ValidatorChain that are not present in ValidatorChainInterface.
Furthemore, the chain that is provided or configured should not, IMO, be mutated after it has been attached.
Proposed Solution
Whether a field is "empty" or not, and whether that matters is a validation concern and should be entirely delegated to the validator chain.
It should be the users responsibility to add sufficient validation to each input for their use case, therefore, I'd suggest:
- Complete removal of
Input::injectNotEmptyValidator(),Input::prepareRequiredValidationFailureMessage()and related methods - Removal of
Input::setRequired()andInput::isRequired()- again, this is a validation concern and part of the chain configuration
Impact to users
… is quite significant…
Any fields/inputs that do not configure validation beyond marking the input as required would pass validation for empty values where previously they would not have.
This could possibly be mitigated by throwing an exception when setRequired() is called, or, the required key is present in a specification, alerting users to the change.
This would force users to audit input filters and specs for sufficient validation.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status