Framework: required_without_all bug

Created on 10 Jan 2016  路  4Comments  路  Source: laravel/framework

All 4 comments

I agree that this is an issue, it's incredibly confusing and doesn't match the description of the validation at all, a similar issue was closed earlier this year #9724 marked as "intended behaviour".

I think either;

A) The documentation clearly needs to explain that this doesn't prevent validation failing when other fields are present (which is what the documentation insinuates)
B) Actually make the validation fail when the other field is present (like what the documentation insinuates)
C) Update the documentation and add another validation rule that actually does this (yes, you can write custom validation rules but I still haven't got them running under Lumen in a Test Case)

I hope you guys agree - it's very confusing.

I have submitted a PR #11927 which fixes this issue.

@sebdesign @GrahamCampbell @derakoola

Was this issue actually fixed with the linked PR? We're still encountering a situation with the latest stable version, where the following setup succeeds even when none of the required_without_all fields are present.

    protected $rules = [
        'job_id'     => 'int|nullable|required_without_all:company_id,user_id|exists:job,id|aclJob',
        'company_id' => 'int|nullable|required_without_all:job_id,user_id|exists:company,id|aclCompany',
        'user_id'    => 'int|nullable|required_without_all:company_id,job_id|exists:user,id|aclUser',
    ];

@sebdesign @GrahamCampbell @derakoola

Was this issue actually fixed with the linked PR? We're still encountering a situation with the latest stable version, where the following setup succeeds even when none of the required_without_all fields are present.

    protected $rules = [
        'job_id'     => 'int|nullable|required_without_all:company_id,user_id|exists:job,id|aclJob',
        'company_id' => 'int|nullable|required_without_all:job_id,user_id|exists:company,id|aclCompany',
        'user_id'    => 'int|nullable|required_without_all:company_id,job_id|exists:user,id|aclUser',
    ];

Yours should be the intended behavior, so if it works, you have no issues. Your complaint is different from OP's issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YannPl picture YannPl  路  3Comments

gabriellimo picture gabriellimo  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments

kerbylav picture kerbylav  路  3Comments