How to use do_action_ref_array?

I haven’t tested this yet but somebody suggested this:

add_action( 'bookly_validate_custom_field', function ( \stdClass $field, &$errors, $cart_key, \stdClass $field_info ) {
    // Validation by custom_field id
    switch ( $field->id ) {
        case 'id_value':
            if ( /*$invalid == */ true ) {
                $errors['custom_fields'][ $cart_key ][ $field->id ] = __( 'Invalid', 'bookly' );
            }
            break;
    }
}, 10, 4 );