Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

pterodactyl/panel

8314 stars
2 code files
View pterodactyl/panel on GitHub

app/Rules/Username.php

Open in GitHub
use Illuminate\Contracts\Validation\Rule;
 
class Username implements Rule
{
public const VALIDATION_REGEX = '/^[a-z0-9]([\w\.-]+)[a-z0-9]$/';
 
public function passes($attribute, $value): bool
{
return preg_match(self::VALIDATION_REGEX, mb_strtolower($value));
}
 
public function message(): string
{
return 'The :attribute must start and end with alpha-numeric characters and
contain only letters, numbers, dashes, underscores, and periods.';
}
 
public function __toString()
{
return 'p_username';
}
}

app/Models/User.php

Open in GitHub
use Pterodactyl\Rules\Username;
 
class User extends Model
{
//
public static function getRules()
{
$rules = parent::getRules();
 
$rules['language'][] = new In(array_keys((new self())->getAvailableLanguages()));
$rules['username'][] = new Username();
 
return $rules;
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.