Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

laravel request validation nullable or sometimes

Fancy Ferret answered on April 18, 2023 Popularity 7/10 Helpfulness 1/10

Contents


More Related Answers

  • form validation nullable laravel
  • laravel request validation boolean
  • return response at failedValidation() in request laravel
  • laravel form request custom error message
  • laravel validation ignore if null
  • laravel 8 validation required if another field is not null
  • how to set a validation on a value if its not null in laravel php
  • how to show validation error in laravel 8
  • field not required validation laravel
  • laravel validation required if not null
  • laravel except request validated to controller
  • laravel return validation errors ajax
  • get all laravel validation failed messages
  • laravel request nullable
  • laravel form request validation api
  • laravel validation allow specific values
  • laravel validation not equal to
  • laravel return validation errors
  • validation in laravel
  • validation laravel
  • dependable validation in laravel
  • sometimes validation in laravel
  • laravel check if request has value
  • laravel request before validation
  • laravel validation required if
  • laravel request validation rules for create and update
  • validate either one field is required in laravel
  • return response at failedValidation() in request laravel
  • laravel validation on update
  • laravel form request validation api

  • laravel request validation nullable or sometimes

    0

    sometimes: Only apply the rest of the validation rules if the field shows up in the request.

    nullable: If the field shows up in the request and is null (undefined, empty, has no value at all, etc), do not apply the rest of the validation rules.


    In other words, if you have a field that might not make it to the request (for instance a form with a <select> field where users might select no value at all), you probably need 'sometimes', because a <select> with no value doesn't return the field key at all, which would throw an error if you try and validate it against 'nullable'. You can then apply additional validation (such as 'exists:table,column') in the event that the request returns the field.


    More information here :

    https://www.leonelngande.com/laravel-validation-sometimes-vs-nullable/

    And here :

    https://rappasoft.com/blog/nullable-vs-sometimes

    Popularity 7/10 Helpfulness 1/10 Language whatever
    Tags: nullable php
    Link to this answer
    Share Copy Link
    Contributed on Apr 18 2023
    Fancy Ferret
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.