Fix User model validation behavior, closes #950
This commit is contained in:
parent
50809cad36
commit
c61c2bc5fd
3 changed files with 23 additions and 0 deletions
|
@ -6,6 +6,9 @@ use Illuminate\Contracts\Validation\Rule;
|
|||
|
||||
class Username implements Rule
|
||||
{
|
||||
/**
|
||||
* Regex to use when validating usernames.
|
||||
*/
|
||||
public const VALIDATION_REGEX = '/^[a-z0-9]([\w\.-]+)[a-z0-9]$/';
|
||||
|
||||
/**
|
||||
|
@ -33,4 +36,15 @@ class Username implements Rule
|
|||
return 'The :attribute must start and end with alpha-numeric characters and
|
||||
contain only letters, numbers, dashes, underscores, and periods.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the rule to a validation string. This is necessary to avoid
|
||||
* issues with Eloquence which tries to use this rule as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return 'p_username';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue