PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 16, 2022

[FIXED] how to validate a field that must be false in laravel form request

 November 16, 2022     laravel-6     No comments   

Issue

I want to set ('is_color' = false) if ('is_variation' = true) in form request

        $rules  = [
            'is_color'                      =>  'nullable|boolean',
            'is_guarantee'                  =>  'nullable|boolean',
            'is_variation'                  =>  'nullable|boolean',
        ];

Solution

It seems not related to the validation, What I found out is you want set is_color due to is_variation's value, so you can validate just is_variation and set is_color. But you can validate these parameter related to each other with make a method named withValidator in your form request. For more information you can see below link: With Validator

Or you can make custom rule validation : Custom Validation in laravel



Answered By - Mehrdad Saami
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing