I have a situation and unfortunately not sure how to sort it out in proper way. I have below script
$validator = Validator::make(
$request->all(),
[
'game_id' => 'required|integer'
],
$messages
);
if ($validator->fails()) {
$response = $validator->messages();
}else{
$response = $gameService->setStatus($request);
}
Now each game has different type, I wanted to add validation on behalf of type. For example if a game is Task Based
then I would add validation for time
which would be mandatory only for Task based game otherwise it would be an optional for other types.
I have three types of games
1 - level_based 2 - task_based 3 - time_based
In the type table, each game has type.
So is there any way to add validation? I want to do it, inside validation function.
Thank you so much.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2WoSW2R
via IFTTT
Aucun commentaire:
Enregistrer un commentaire