0
0
Laravelframework~10 mins

Available validation rules in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to require the 'email' field to be a valid email address.

Laravel
'email' => '[1]',
Drag options to blanks, or click blank then click option'
Astring
Bnullable|email
Crequired|numeric
Drequired|email
Attempts:
3 left
💡 Hint
Common Mistakes
Using only 'email' without 'required' allows empty input.
Using 'numeric' instead of 'email' causes validation failure.
2fill in blank
medium

Complete the code to validate that the 'age' field is an integer and at least 18.

Laravel
'age' => '[1]',
Drag options to blanks, or click blank then click option'
Anumeric|max:18
Bstring|min:18
Cinteger|min:18
Drequired|email
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' instead of 'integer' causes type mismatch.
Using 'max:18' instead of 'min:18' allows younger ages.
3fill in blank
hard

Fix the error in the validation rule to require the 'password' field to be at least 8 characters.

Laravel
'password' => 'required|[1]:8',
Drag options to blanks, or click blank then click option'
Amin
Bmax
Csize
Ddigits
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max:8' limits password to 8 characters maximum.
Using 'digits' applies only to numeric input.
4fill in blank
hard

Fill both blanks to validate 'username' is required and unique in the 'users' table.

Laravel
'username' => '[1]|[2]:users',
Drag options to blanks, or click blank then click option'
Arequired
Bemail
Cunique
Dnullable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'nullable' instead of 'required' allows empty usernames.
Using 'email' instead of 'unique' does not check database uniqueness.
5fill in blank
hard

Fill all three blanks to validate 'title' is required, a string, and has a maximum length of 255.

Laravel
'title' => '[1]|[2]|[3]:255',
Drag options to blanks, or click blank then click option'
Arequired
Bstring
Cmax
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'min' instead of 'max' limits minimum length, not maximum.
Omitting 'string' allows non-text input.