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
There is no way to make a validator, then afterwards appending an error to the validator and then checking if it failed, then it would return false for errors and then act as it succeeded.
$validator = Validator::make($request->all(), [
'textField' => 'string|max:1'
]);
$validator->getMessageBag()->add('password', 'Wrong password.');
// or
$validator->errors()->add('password', 'Wrong password.');
if (!$validator->fails()) { // This would pass since the appending error is not acutally added into the fails event
return true;
}
return $validator->messages()->get('*');
I might be new at Laravel, so there might be a solution to this then please enlighten me. I have not been able to find it, even tho I think I have searched the internet dry and looked at the function, so I have to make a wacky workaround, would just be nice if Laravel supported this, when it already has a validator that we can use.
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.
-
Hi,
There is no way to make a validator, then afterwards appending an error to the validator and then checking if it failed, then it would return false for errors and then act as it succeeded.
Clearly explained here: https://stackoverflow.com/a/46052843/1288867
I might be new at Laravel, so there might be a solution to this then please enlighten me. I have not been able to find it, even tho I think I have searched the internet dry and looked at the function, so I have to make a wacky workaround, would just be nice if Laravel supported this, when it already has a validator that we can use.
Best regards,
Casper Thomsen
Beta Was this translation helpful? Give feedback.
All reactions