Closed autowp closed 6 years ago
A usage example is posting json to RESTful API and filter incoming data with optional boolean fields.
Whatever "field is required" message to an optional field is always incorrect regardless of wanting that by someone.
I don't understand what you're trying to say.
Tests are required anyway: a test will clarify the ambiguity
I agree with @Erikvv here. If you are submitting values via an API, and have an actual boolean false
value submitted, the value is not empty. In those cases, you're likely expecting a boolean, and you would want to validate it as such. If the value is supposed to be another type entirely, I'd argue allowing false
as an empty value would be inconsistent, because if you allow_empty
, you're now getting a value of the wrong type.
As such, I'm closing this request. If you feel strongly about it, re-open with unit tests, and discussion of the specific use cases.
I don't think it is useful to consider
false
as empty, I don't remember ever wanting that.But it is consistent with Zend\Validator\NotEmpty