Changeset View
Changeset View
Standalone View
Standalone View
src/app/Rules/UserEmailLocal.php
Show All 28 Lines | class UserEmailLocal implements Rule | ||||
* @param string $attribute Attribute name | * @param string $attribute Attribute name | ||||
* @param mixed $login Local part of email address | * @param mixed $login Local part of email address | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function passes($attribute, $login): bool | public function passes($attribute, $login): bool | ||||
{ | { | ||||
// Strict validation | // Strict validation | ||||
if (!preg_match('/^[A-Za-z0-9_.-]+$/', $login)) { | if ( | ||||
empty($login) | |||||
|| !is_string($login) | |||||
|| !preg_match('/^[A-Za-z0-9_.-]+$/', $login) | |||||
) { | |||||
$this->message = \trans('validation.entryinvalid', ['attribute' => $attribute]); | $this->message = \trans('validation.entryinvalid', ['attribute' => $attribute]); | ||||
return false; | return false; | ||||
} | } | ||||
// Standard email address validation | // Standard email address validation | ||||
$v = Validator::make([$attribute => $login . '@test.com'], [$attribute => 'required|email']); | $v = Validator::make([$attribute => $login . '@test.com'], [$attribute => 'required|email']); | ||||
if ($v->fails()) { | if ($v->fails()) { | ||||
$this->message = \trans('validation.entryinvalid', ['attribute' => $attribute]); | $this->message = \trans('validation.entryinvalid', ['attribute' => $attribute]); | ||||
Show All 27 Lines |