mirror of
https://github.com/anonaddy/anonaddy
synced 2026-04-26 01:25:06 +02:00
27 lines
580 B
PHP
27 lines
580 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
class ValidAliasLocalPart implements ValidationRule
|
|
{
|
|
/**
|
|
* Indicates whether the rule should be implicit.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public $implicit = true;
|
|
|
|
/**
|
|
* Run the validation rule.
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if (! preg_match('/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))$/', $value)) {
|
|
$fail('Invalid alias local part.');
|
|
}
|
|
}
|
|
}
|