You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My goal is to display different validation messages depending on the condition that hoge violates.
For instance, if hoge fails the before_or_equal:foo condition, I want to display the message "hoge must be before or equal to foo."
Similarly, if it fails the before_or_equal:piyo condition, I want to show "hoge must be before or equal to piyo."
I attempted to override the messages method as follows:
publicfunctionmessages()
{
return [
'hoge.before_or_equal:foo' => 'hoge must be before or equal to foo',
'hoge.before_or_equal:piyo' => 'hoge must be before or equal to piyo',
];
}
However, this approach doesn't seem to work.
Can anyone advise on how to achieve this in Laravel?
Any help would be greatly appreciated. Thank you!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone, I'm new to Laravel and have a question that might be simple for the experienced.
I'm trying to assign multiple messages to a single validation rule within a FormRequest class.
Here's what my validation rule looks like:
My goal is to display different validation messages depending on the condition that hoge violates.
For instance, if hoge fails the before_or_equal:foo condition, I want to display the message "hoge must be before or equal to foo."
Similarly, if it fails the before_or_equal:piyo condition, I want to show "hoge must be before or equal to piyo."
I attempted to override the messages method as follows:
However, this approach doesn't seem to work.
Can anyone advise on how to achieve this in Laravel?
Any help would be greatly appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions