-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Before/After validation rules ignore the validation state of the dependent field #49863
Comments
Please reopen the issue as this has not been actually fixed. The PR #49871 has been reverted. |
@naquad since it seems not possible right now to solve this we're not going to make any changes here. If you want, you can attempt a PR at the docs to explain this gotcha. |
I'm trying to wrap my head around all related cases and the issue that has caused the reversal. The issues are: In summary, they are about the null behavior which is something like this (but I'm not sure about it): null in the comparison always yields true (no idea why, it's just the expectation). There's also some strange syntax like Am I getting it right that the fix has been blocked by some new feature? This is not a "gotcha". That's a bug. The Validator must be bulletproof, otherwise malicious input may cause some epic failures. A case: mail log channel for errors is configured and someone is sending dozens (not even thousands) of requests with malicious payload causing you to lose the mail channel effectively as your emails will be throttled/marked as spam very quickly. I honestly doubt someone has a special test that tries to stuff random invalid payloads into all validation rules of every endpoint they have with the corresponding extra handling for the corner cases. Everyone relies on the fact that the Validator can't broken by the input and will return the invariant of the data that can be handled by the user code. |
Laravel Version
10.34.2
PHP Version
8.3.2
Database Driver & Version
No response
Description
Validator's
before
andafter
rules are trying to construct the second operand from non-validated potentially invalid data (ValidatesAttributes::compareDates() is retrieving the data using Validator::getValue() which returns raw data). This causes unexpected exceptions.Steps To Reproduce
Sample script
Output
Expected result
Validation exception stating that both values are invalid.
Actual result
TypeError fatal error.
The text was updated successfully, but these errors were encountered: