-
Notifications
You must be signed in to change notification settings - Fork 11k
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
How can we access the value inside the callback of Rule::when(), when the field is an array. #38865
Comments
The framework/src/Illuminate/Validation/ValidationRuleParser.php Lines 285 to 307 in 1b2107e
This is the most important part of your question that has been excluded. What is the conditional you need to check? Some other validation features may cover the requirement.
|
Thanks, it solved the issue. |
Thanks @derekmd |
Description:
How can we access the value inside the callback of Rule::when(), when the field is an array.
I guess we may pass the current value as the second parameter to the callback.
$validator = Validator::make($request->all(), [
'openings.*.from' => ['required_with:openings.*.id', 'date_format:H:i'],
'openings.*.to' => ['required_with:openings.*.id', Rule::when(function($a){
// Need the current value for conditional check
},['date_format:H:i']), 'after:openings.*.from'],
]);
If we wanted to add validation(date_format:H:i) on the basis of the current value of openings's to.
But I can not access the value of current openings to.
Originally posted by @itxshakil in #38361 (comment)
Steps To Reproduce:
The text was updated successfully, but these errors were encountered: