Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Zyberg's avatar

How to exclude specific items from request validation?

I want to pass an object that has an array of $items to a validator and each of the items would have an action field, which would hold a value of 'deleted' or anything else.

I have complex validation for those items using a wildcard (example: items.*.somefield => 'required'). However, I don't want to apply any validation, if an item has action: 'deleted'. That poses a problem to me because I am using wildcards to access all the items...

I've looked into sometimes rule and documentation, but didn't find any examples fitting the case...

0 likes
1 reply
Zyberg's avatar

Found a way to do it in a dumb manner: loop over each item and create specific validation rules for it. But I would really be happier, if it were possible to do it in a less mundane and verbose way...

Please or to participate in this conversation.