Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type to incorrect input messages #492

Closed
arogachev opened this issue Dec 26, 2022 · 11 comments · Fixed by #736
Closed

Add type to incorrect input messages #492

arogachev opened this issue Dec 26, 2022 · 11 comments · Fixed by #736
Assignees
Labels
polar severity:BC breaking Breaks backwards compatibility type:enhancement Enhancement
Milestone

Comments

@arogachev
Copy link
Contributor

arogachev commented Dec 26, 2022

Currently:

private string $incorrectInputMessage = 'Value must be an array or an object.',

Added recently:

private string $incorrectInputMessage = 'The allowed types are integer, float, string, boolean. {type} given.',

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@arogachev arogachev self-assigned this Dec 26, 2022
@arogachev arogachev added the type:enhancement Enhancement label Dec 26, 2022
@arogachev arogachev removed their assignment Dec 26, 2022
@samdark samdark added this to the 1.1.0 milestone Dec 26, 2022
@cebe
Copy link
Member

cebe commented Feb 3, 2023

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.

@arogachev
Copy link
Contributor Author

@cebe See the 2nd part of response here - #514 (comment). 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

@arogachev
Copy link
Contributor Author

@cebe You are suggesting to be able to configure different behavior for API (throw exceptions) and forms (show messages), right?

@arogachev
Copy link
Contributor Author

Kind of related - #526.

@vjik
Copy link
Member

vjik commented Feb 3, 2023

Throw exception is not validator task. If it need, then should be code that process validator results and throw exception if need.

@cebe
Copy link
Member

cebe commented Feb 8, 2023

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.

@cebe cebe modified the milestones: 1.1.0, 1.0.0 Feb 8, 2023
@cebe
Copy link
Member

cebe commented Feb 8, 2023

Changed the milestone as I consider this a major design issue in how a validation library should work.

@arogachev
Copy link
Contributor Author

@cebe This issue is only about providing more details in the error message by adding the extra parameter. Created a separate issue - #546.

@samdark
Copy link
Member

samdark commented Feb 9, 2023

@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?

@cebe
Copy link
Member

cebe commented Feb 9, 2023

@samdark answered in #546 (comment)

@samdark samdark removed this from the 1.0.0 milestone Feb 22, 2023
@polar-sh polar-sh bot added the polar label Jul 21, 2023
@arogachev arogachev added the severity:BC breaking Breaks backwards compatibility label May 24, 2024
@samdark samdark added this to the 2.0 milestone May 28, 2024
@arogachev arogachev linked a pull request Jul 29, 2024 that will close this issue
@vjik
Copy link
Member

vjik commented Jul 31, 2024

Done by #736

@vjik vjik closed this as completed Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polar severity:BC breaking Breaks backwards compatibility type:enhancement Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants