Custom validation functions

In my form, I have two items, “Link” and “File”.

The “Link” item is a classic WWW link, which is a text string.

To enter the “File” item, I use the file upload function

$uploadValidations = [
'maxUploadSize' => '10M', //ex. '10MB' (Mega Bytes), '1067KB' (Kilo Bytes), '5000B' (Bytes)
'minUploadSize' => '1K', // 1 Kilo Byte
'allowedFileTypes' => [
'gif', 'jpeg', 'jpg', 'png', 'pdf'
]
];
$crud->setFieldUpload('file', $this->adresar_uploads, base_url() . $this->adresar_uploads, $uploadValidations);

The “Link” and “File” items are items where at least one of them must be filled in. This means that both cannot be empty, unfilled.

Therefore, I wrote my own function for validation

\Valitron\Validator::addRule('check_odkaz_soubor', function($field, $value, array $params, array $fields)
{
$odkaz = $fields['odkaz'];
$soubor = $fields['soubor'];

if((trim($odkaz) == '') && (trim($soubor) == ''))
{
return FALSE;
}
else
{
return TRUE;
}//if
}, 'Musí být vyplněná bližší informace a to buď "Odkaz" a nebo "Soubor".');

But during testing I found that if the items are empty, not filled in, the validation does not start at all ;-(

So I tried to use the validation rule ‘requiredWithout’ in this way

$crud->setRule('link', 'requiredWithout', ['file']);
$crud->setRule('file', 'requiredWithout', ['link']);

But I came across that when a file is specified, the Validator evaluates that nothing is specified and prints an error.

Can you please think of a solution to my problem?

All I can think of is to write functions for checking when inserting (callbackBeforeInsert) and the same for updating (callbackBeforeUpdate). But I would consider that as a last resort, because the error message is printed before saving.

Please advise