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

Fix required_without rule bug. #1742

Merged
merged 2 commits into from
Feb 19, 2019

Conversation

bangbangda
Copy link
Contributor

Description

  • Unable to get the value of the validation field correctly.
  • Update validation class document.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • [] Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@lonnieezell lonnieezell merged commit 711aec1 into codeigniter4:develop Feb 19, 2019
@niteraven7
Copy link

niteraven7 commented Feb 19, 2019

@lonnieezell @bangbangda No, this does NOT fix this rule. I have a form that requires an email address OR phone number OR both. The validation rules are as follows:

public $recipient = [ 'first_name' => 'required|min_length[1]|max_length[50]', 'last_name' => 'required|min_length[1]|max_length[50]', 'email' => 'required_without[number]|valid_email', 'number' => 'required_without[email]|numeric', ];

I believe the validation code should look like:

if (empty($data[$field])) { return false; }

The field becomes required when any of the parameter fields are empty (not present or not set). Does that make sense?

@bangbangda
Copy link
Contributor Author

@niteraven7
Check my PR
Empty is not ok, empty("0") is true.
Trim is ok.

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

Successfully merging this pull request may close these issues.

3 participants