Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多维数组验证使用requiredIf时,无法使用 #35

Open
CyanChenQ opened this issue Feb 1, 2021 · 0 comments
Open

多维数组验证使用requiredIf时,无法使用 #35

CyanChenQ opened this issue Feb 1, 2021 · 0 comments
Assignees

Comments

@CyanChenQ
Copy link

// src/Traits/ScopedValidatorsTrait.php
public function requiredIf(string $field, $fieldVal, string $anotherField, $values): ?bool
    {
       // 此处验证二维数组字段时,$anotherField可能时‘test.field1’, isset为false
        if (isset($this->data[$anotherField])) {
            $anotherVal = $this->data[$anotherField];

            // if (in_array($anotherVal, (array)$values, true)) {
            if (Helper::inArray($anotherVal, (array)$values)) {
                return $this->required($field, $fieldVal);
            }
        }

        return null;
    }
@inhere inhere self-assigned this Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants