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

Fixes an issue where boolean false set on deterministic fields are treated unexpectedly in requireWith and requireWithout validators. #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RickKukiela
Copy link

Adds $checkBool flag in the requireWith and requireWithout validators which increase the specificity check on the deterministic field(s) in order to correctly treat a value of (bool)false as "not set". When not enabled, the old behavior of treating (bool)false as "set" is maintained. The flag was added in order to maintain backward compatibility.

Full notes in commit log.

…lidators which increase the specificity check on the deterministic field(s) in order to correctly treat a value of (bool)false as "not set". When not enabled, the old behavior of treating (bool)false as "set" is maintained. The flag was added in order to maintain backward compatibility.

- Updates the README.md file to include details on using the new `$checkBool` flag on the `requiredWith` and `requiredWithout` validator sections. Example uses are included.

- Updates the `tests/Valitron/ValidateTest.php` to duplicate all existing tests for `requiredWith` and `requiredWithout` but with the `$checkBool` flag enabled to verify backward compatibility. All tests pass.

- Fixes the `testCreditCardInvalid()` and `testCreditCardValid()` methods by providing the card numbers as strings since the integer values were being converted to exponential notation on some environments causing the tests to fail. The credit card tests now pass.

- Fixes a deprecation warning in `ValidateAddInstanceRuleTest::testUniqueRuleName()` where `$this->assertRegExp()` was deprecated. Replaced assert call with recommended replacement `$this->assertMatchesRegularExpression()`. The test now passes without warning.

- Fixes a few other minor English / grammatical errors in the README.md and comments in the `requiredWith` and `requiredWithout` validators.
@RickKukiela RickKukiela changed the title Fixes an issue boolean false set on deterministic fields are treated unexpectedly in requireWith and requireWithout validators. Fixes an issue where boolean false set on deterministic fields are treated unexpectedly in requireWith and requireWithout validators. Jul 2, 2022
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.

None yet

1 participant