mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
35 lines
630 B
PHP
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';
|
|
}
|
|
}
|