flexisip-account-manager/flexiapi/app/Rules/Vcard.php
2024-04-24 13:41:43 +00:00

35 lines
630 B
PHP

<?php
namespace App\Rules;
use Sabre\VObject;
use Illuminate\Contracts\Validation\Rule;
class Vcard implements Rule
{
private $message = null;
public function __construct()
{
//
}
public function passes($attribute, $value): bool
{
try {
$vcard = VObject\Reader::read($value);
if (!empty($vcard->validate())) return false;
if ($vcard->UID == null) return false;
return true;
} catch (\Throwable $th) {
return false;
}
}
public function message()
{
return 'Invalid vcard passed';
}
}