Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 5 MCQs Laravel Form validation

INT221 — Mvc Programming 50 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 50 answered 0 right 0 wrong , 50 left

  1. Question 1 of 50

    What is the primary purpose of the CSRF token in Laravel forms?

  2. Question 2 of 50

    Which Blade directive is used to generate the hidden CSRF token input field inside a form?

  3. Question 3 of 50

    If a POST request is made to a Laravel route without a valid CSRF token, which HTTP status code is typically returned?

  4. Question 4 of 50

    HTML forms natively support which of the following HTTP verbs?

  5. Question 5 of 50

    Which Blade directive helps in performing 'Method Spoofing' to simulate PUT or DELETE requests?

  6. Question 6 of 50

    What is the name of the hidden input field used by Laravel to determine the spoofed HTTP method?

  7. Question 7 of 50

    In a controller, which method is most commonly called on the $request object to validate incoming data?

  8. Question 8 of 50

    What happens automatically when the $request->validate() method fails?

  9. Question 9 of 50

    Which validation rule ensures that a field must be present in the input data and not empty?

  10. Question 10 of 50

    How can you specify multiple validation rules for a single field using the pipe syntax?

  11. Question 11 of 50

    Which data structure can be used as an alternative to the pipe syntax for defining rules?

  12. Question 12 of 50

    Which validation rule checks if two fields (e.g., password and password_confirmation) have the same value?

  13. Question 13 of 50

    What does the unique:users validation rule check?

  14. Question 14 of 50

    If you want a field to be optional but validated if it is present, which rule should typically accompany specific constraints?

  15. Question 15 of 50

    Which variable is automatically shared with all views to display validation errors?

  16. Question 16 of 50

    How do you check if there are any validation errors in a Blade view?

  17. Question 17 of 50

    Which method retrieves the first error message for a specific field?

  18. Question 18 of 50

    Which Blade directive allows you to quickly check for validation errors on a specific field and display them?

  19. Question 19 of 50

    Consider the following code inside a Blade view:

    blade
    @error('title')
    <div class="alert alert-danger">{{ $message }}</div>
    @enderror

    What does the $message variable contain?

  20. Question 20 of 50

    To repopulate a form field with its previous value after a validation failure, which helper function is used?

  21. Question 21 of 50

    What is the second argument of the old() helper function used for? e.g. old('email', $user->email)

  22. Question 22 of 50

    Which Artisan command creates a new custom validation rule class?

  23. Question 23 of 50

    In a custom Rule class implementing Illuminate\Contracts\Validation\Rule, which method contains the validation logic?

  24. Question 24 of 50

    In a custom Rule class, what is the purpose of the message() method?

  25. Question 25 of 50

    Which validation rule stops the validation process for a field immediately after the first failure?

  26. Question 26 of 50

    How would you validate that an uploaded file is an image?

  27. Question 27 of 50

    What is the correct syntax to define a custom error message for a specific rule on a specific attribute in the validate method?

  28. Question 28 of 50

    Correction on previous logic: In $request->validate($rules, $messages), the messages array is passed as which argument?

  29. Question 29 of 50

    Which rule checks that a value is within a given list of values?

  30. Question 30 of 50

    What does the max:255 rule implies when validating a numeric field?

  31. Question 31 of 50

    What does max:1024 imply when validating a file upload?

  32. Question 32 of 50

    How can you validate nested array input, for example, checking the name of every person in a people array?

  33. Question 33 of 50

    Which rule ensures a string is a valid URL?

  34. Question 34 of 50

    Which of the following is NOT a valid way to specify a custom validation rule?

  35. Question 35 of 50

    When using a Closure for custom validation, how do you signal a failure?

  36. Question 36 of 50

    What is the purpose of the FormRequest class in Laravel?

  37. Question 37 of 50

    In a FormRequest class, what does the authorize() method do?

  38. Question 38 of 50

    Which rule validates that the field under validation matches a given regular expression?

  39. Question 39 of 50

    To use the regex rule inside a pipe-delimited string, what must you be careful about?

  40. Question 40 of 50

    If you want to validate a date and ensure it is after a specific date (e.g., tomorrow), which rule would you use?

  41. Question 41 of 50

    Which method is used to retrieve validated data from a FormRequest instance?

  42. Question 42 of 50

    Why might you get a TokenMismatchException?

  43. Question 43 of 50

    How can you exclude specific URIs from CSRF protection?

  44. Question 44 of 50

    The accepted validation rule is commonly used for:

  45. Question 45 of 50

    What is the key difference between size rule and min/max rules?

  46. Question 46 of 50

    Which rule validates that the value must exist in a given database table?

  47. Question 47 of 50

    When repopulating forms, what does <input type="text" name="email" value="{{ old('email') }}"> ensure?

  48. Question 48 of 50

    If you need to validate a boolean value, which rule should be used?

  49. Question 49 of 50

    In a Blade template, how is the $errors variable passed to the view?

  50. Question 50 of 50

    Which validation rule is the opposite of accepted?

That's unit 5

Answer a few questions and your score shows up here.