We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multiple field process Phalcon\Validation\Validator\Callback

Hi, i want to using the Callback validator with multiple field like this

$validator->add(
    ['is_digital', 'is_preorder'],
    new Phalcon\Validation\Validator\Callback(
        [
            'callback' => function($data) {
                return is_bool($data); // <- how to handle them in in single command?
                /**
                 * Is need to using 'throw new Exception' for each field?
                 */
            },
            'message' => ':field must boolean'
        ]
    ));

Did i need doing that in separate command?

$validator->add(
    ['is_digital', 'is_preorder'],
    new Phalcon\Validation\Validator\Callback(
        [

            'callback' =>  [
                'is_digital' => function(){},
                'is_preorder' => function(){}
            ]
            'message' => [
                'is_digital' => 'error',
                'is_preorder' => 'error',
            ]
        ]
    ));