0
0
Laravelframework~20 mins

Available validation rules in Laravel - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Laravel Validation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does the 'required' validation rule do in Laravel?
In Laravel, what is the behavior of the 'required' validation rule when applied to a form input?
AIt checks if the input is a valid email address.
BIt allows the input field to be empty or missing without error.
CIt ensures the input field must be present and not empty.
DIt validates that the input is a numeric value.
Attempts:
2 left
💡 Hint
Think about whether the field can be left blank or missing.
component_behavior
intermediate
2:00remaining
What output does this Laravel validation produce?
Given this validation rule in a Laravel controller:
$request->validate(['age' => 'integer|min:18']);

What happens if the input 'age' is '17'?
AValidation fails because age is less than 18.
BValidation passes because 17 is an integer.
CValidation passes because min rule is ignored for integers.
DValidation fails because age is not a string.
Attempts:
2 left
💡 Hint
Check what the 'min:18' rule means for integers.
📝 Syntax
advanced
2:00remaining
Which validation rule syntax is correct for checking a valid email in Laravel?
Select the correct syntax to validate that an input named 'email' is a valid email address in Laravel.
A'email' => 'required|email'
B'email' => 'email|required'
C'email' => 'email|required|numeric'
D'email' => 'required|email_address'
Attempts:
2 left
💡 Hint
Order matters for readability but not for correctness; check rule names carefully.
🔧 Debug
advanced
2:00remaining
Why does this Laravel validation rule cause an error?
Consider this validation rule:
'username' => 'required|min:3|max'

Why will this cause a validation error?
AThe 'min' rule must come after 'max'.
BThe 'max' rule is missing a value and causes a syntax error.
CThe 'required' rule cannot be combined with 'min' or 'max'.
DThe 'username' field must be numeric for 'min' and 'max' to work.
Attempts:
2 left
💡 Hint
Check if all rules have required parameters.
state_output
expert
2:00remaining
What is the validation result for this Laravel rule with input 'tags'?
Given this validation rule:
'tags' => 'array|min:2'

And the input:
tags = ['php']

What is the validation result?
AValidation passes because 'array' rule ignores 'min'.
BValidation passes because 'min:2' applies only to strings.
CValidation fails because 'tags' is not a string.
DValidation fails because the array has fewer than 2 items.
Attempts:
2 left
💡 Hint
Consider how 'min' works with arrays in Laravel validation.