22 lines
543 B
PHP
22 lines
543 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Rules;
|
||
|
|
||
|
use Closure;
|
||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||
|
use Illuminate\Support\Facades\Crypt;
|
||
|
|
||
|
class DNExists implements ValidationRule
|
||
|
{
|
||
|
/**
|
||
|
* Run the validation rule.
|
||
|
*
|
||
|
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||
|
*/
|
||
|
public function validate(string $attribute,mixed $value,Closure $fail): void
|
||
|
{
|
||
|
if (! config('server')->fetch($x=Crypt::decryptString($value)))
|
||
|
$fail(sprintf('The DN %s doesnt exist.',$x));
|
||
|
}
|
||
|
}
|