So in a Request we have some validation, where the type field will be review, which means the body field has to have a minimum of 6 characters.
public function rules(){
return [
'type' => 'required|in:star_rating,review',
'body' => 'required_if:type,review|min:6'
];
}
However, the issue is that when the type is star_rating, I get an error that The body must be at least 6 characters.
This should not happen, since the body is optional and ONLY should be required and validated with min:6 if type is review. I can't seem to figure out why it runs the min:6 validation on it even if the type is star_rating.
Any idea how to get it to work as intended?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire