Add type to incorrect input messages
Currently:
https://github.com/yiisoft/validator/blob/e3a6c11847f550a5ed39eb1254b06b04331dd3d5/src/Rule/AtLeast.php#L38
Added recently:
https://github.com/yiisoft/validator/blob/dfdf19e71f83931d2a62b48a9d7f41eee79d2461/src/Rule/BoolValue.php#L83
Funding
- You can sponsor this specific effort via a Polar.sh pledge below
- We receive the pledge once the issue is completed & verified
Are these messages intended to be shown to end users? I understand validation message in case of an API, when it is shown to a developer. In case of a HTML form, this messages happing sounds like a programming error and should rather be an excepction than a message shown to the user.
@cebe See the 2nd part of response here - https://github.com/yiisoft/validator/pull/514#discussion_r1092912975. At some point there were such exceptions. But then we discussed it and decided that handlers should not throw exceptions related with wrong input data. @vjik
@cebe You are suggesting to be able to configure different behavior for API (throw exceptions) and forms (show messages), right?
Kind of related - #526.
Throw exception is not validator task. If it need, then should be code that process validator results and throw exception if need.
Not sure about the correct solution but the point here is to differentiate between validation messages for a user and error messages for the programmer.
Definition:
Validation message for a user is a message displayed for the user that the user can understand and most importantly allows the user to fix the input.
Error message for the programmer is a message that comes up when the validator is fed with data that can not appear in normal circumstances when users are filling the form, but somehow happen due to an error in the program. In this case the user is very likely not able to correct the input themselfs because the program has a bug. It does not make sense to show these messages to the user.
Changed the milestone as I consider this a major design issue in how a validation library should work.
@cebe This issue is only about providing more details in the error message by adding the extra parameter. Created a separate issue - #546.
@cebe what do you want to do with these errors? Would you somehow handle it differently from the rest of validation errors? Would you hide these from end users?
@samdark answered in https://github.com/yiisoft/validator/issues/546#issuecomment-1423891838
Done by #736