You would need something like this
$rules->add(function ($entity, $options) {
return ($entity->a == 1) && ($entity->b == 1);
}, 'aAndBAreOne');
Or if the check is more complicated than use an entity method
https://book.cakephp.org/3.0/en/orm/validation.html#using-entity-methods-as-rules