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

ale1981's avatar

Validate field value against another with arrays

I am using the following in the rules array of Requester but it doesn't work, any ideas?

'variantStock.*.min'        => "required|numeric|max:variantStock.*.max"

The min field from the array should not be greater than the max field.

0 likes
4 replies
ale1981's avatar

I tried that with;

    Validator::extend('less_than', function($attribute, $value, $parameters) {
        $other = \Input::get($parameters[0]);
        return isset($other) and intval($value) < intval($other);
    });

but again, I don't think the array part of the rules is working when I pass in the field to validate against;

'variantStock.*.min'        => "required|numeric|less_than:variantStock.*.max"

Please or to participate in this conversation.