4 years ago

Validation: Only run exists validation if input is not empty array

Posted 4 years ago by henninghorn

Is it possible to only run a validation if an input is a filled array and not an empty array?

I wan't to be able to update an article with an empty tags array, which means that all tags should be removed via Eloquents sync method. But in my validation I check if the tags input is an array and if the tag ids posted in that array exists - so when I post an empty array, the validation fails.

How can change this behaviour?

Please sign in or create an account to participate in this conversation.