mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 10:21:37 +00:00
23 lines
508 B
PHP
Executable File
23 lines
508 B
PHP
Executable File
<?php
|
|
|
|
namespace App\ValidationRules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use phpseclib3\Crypt\PublicKeyLoader;
|
|
use phpseclib3\Exception\NoKeyLoadedException;
|
|
|
|
class SshKeyRule implements ValidationRule
|
|
{
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
try {
|
|
PublicKeyLoader::load($value);
|
|
|
|
return;
|
|
} catch (NoKeyLoadedException) {
|
|
$fail('Invalid key')->translate();
|
|
}
|
|
}
|
|
}
|