1. Laravel

username / alphanumeric validation in Laravel

Laravel provide a rich set of pre-bult validation rules.

If you need to validate alpha – numeric value you can use –

alpha

The field under validation must be entirely alphabetic characters.

alpha_dash

The field under validation may have alpha-numeric characters, as well as dashes and underscores.

alpha_num

The field under validation must be entirely alpha-numeric characters.

integer

The field under validation must be an integer.

max:value

The field under validation must be less than or equal to a maximum value.
Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.

min:value

The field under validation must have a minimum value.
Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.

numeric

The field under validation must be numeric.

Example

        $request->validate([
            'username' => 'required|alpha_dash|min:4|max:15|unique:users',
        ]);

For more details – https://laravel.com/docs/master/validation

Some Username validation rules in popular platforms

Skype
Min: 6
Max: 32
Can contain: a-z A-Z 0-9 . , _ –
Other: Must start with a letter

Twitter
Min: 1
Max: 15
Can contain: a-z A-Z 0-9 _

Facebook
Min: 5
Max: 50
Can contain: a-z A-Z 0-9 .

Steam
Min: 2
Max: 32
Can contain: a-z A-Z 0-9 _ –

YouTube
Min: 6
Max: 20
Can contain: a-z A-Z 0-9

Twitch
Min: 1
Max: 25
Can contain: a-z A-Z 0-9 _

GitHub
Min: 1
Max: 39
Can contain: a-z A-Z 0-9 –
Other: Can not start with a dash

reddit
Min: 3
Max: 20
Can contain: a-z A-Z 0-9 _ –

https://arshohag.rdevs.xyz
Do you like Ashiqur Rahman's articles? Follow on social!
Comments to: username / alphanumeric validation in Laravel

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

Login

Welcome to rDevs

Brief and amiable onboarding is the first thing a new user sees in the theme.
Join rDevs

start writing