Uh oh!
There was an error while loading. Please reload this page.
fix: validation rule matches and differs - #8122
Merged
kenjis merged 5 commits intoNov 7, 2023
Merged
Conversation
kenjis
marked this pull request as draft
October 29, 2023 21:15
matches and differsmatches and differskenjis
commented
Oct 29, 2023
MemberAuthor
CI3's behaviors: publicfunctiontest_rule_matches()
{
$rules = array(
array('field' => 'foo', 'label' => 'label', 'rules' => 'required'),
array('field' => 'bar', 'label' => 'label2', 'rules' => 'matches[foo]')
);
$values_base = array('foo' => 'sample');
$this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'sample'))));
$this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ''))));
$this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => 'Sample'))));
$this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ' sample'))));
$this->assertFalse($this->run_rules($rules, []));
$this->assertFalse($this->run_rules($rules, ['foo' => null]));
$this->assertFalse($this->run_rules($rules, ['bar' => null]));
$this->assertFalse($this->run_rules($rules, ['foo' => null, 'bar' => null]));
$this->assertTrue($this->run_rules($rules, ['foo' => 1.2, 'bar' => 1.2]));
$this->assertFalse($this->run_rules($rules, ['foo' => 1.2, 'bar' => 2.3]));
$this->assertTrue($this->run_rules($rules, ['foo' => true, 'bar' => true]));
}
publicfunctiontest_rule_differs()
{
$rules = array(
array('field' => 'foo', 'label' => 'label', 'rules' => 'required'),
array('field' => 'bar', 'label' => 'label2', 'rules' => 'differs[foo]')
);
$values_base = array('foo' => 'sample');
$this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'does_not_match'))));
$this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'Sample'))));
$this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => ' sample'))));
$this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => 'sample'))));
$this->assertFalse($this->run_rules($rules, []));
$this->assertFalse($this->run_rules($rules, ['foo' => null]));
$this->assertFalse($this->run_rules($rules, ['bar' => null]));
$this->assertFalse($this->run_rules($rules, ['foo' => null, 'bar' => null]));
$this->assertFalse($this->run_rules($rules, ['foo' => 1.2, 'bar' => 1.2]));
$this->assertTrue($this->run_rules($rules, ['foo' => 1.2, 'bar' => 2.3]));
$this->assertFalse($this->run_rules($rules, ['foo' => true, 'bar' => true]));
} |
kenjisforce-pushed
the
fix-validation-matches-and-differs
branch
from
October 29, 2023 21:44
0200da4 to
36c0de9Compare5 tasks
kenjisforce-pushed
the
fix-validation-matches-and-differs
branch
from
November 2, 2023 07:57
d90fc02 to
b156c13Comparekenjis
marked this pull request as ready for review
November 2, 2023 07:57
kenjis
commented
Nov 2, 2023
MemberAuthor
add docs. |
kenjisforce-pushed
the
fix-validation-matches-and-differs
branch
from
November 2, 2023 08:02
b156c13 to
b154caeCompare👋 Hi, @kenjis! |
kenjisforce-pushed
the
fix-validation-matches-and-differs
branch
from
November 3, 2023 00:43
b154cae to
db0ad7eCompareMGatner
reviewed
Nov 5, 2023
Uh oh!
There was an error while loading. Please reload this page.
MGatner
approved these changes
Nov 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Note: Adding
?stringin CI4 makes the behavior different from that of CI3. There may be similar bugs in other Traditional Rules.Checklist: