Skip to content

Commit 045fd33

Browse files
authored
Fix #169: Set rule option skipOnError to false by default (#170)
1 parent 567447b commit 045fd33

19 files changed

Lines changed: 70 additions & 70 deletions

src/Rule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract class Rule implements RuleInterface, ParametrizedRuleInterface, Formatt
1313
{
1414
private ?FormatterInterface $formatter = null;
1515
private bool $skipOnEmpty = false;
16-
private bool $skipOnError = true;
16+
private bool $skipOnError = false;
1717

1818
/**
1919
* @var callable|null

tests/AbstractDataSetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testResult(array $dataSet, array $rules): void
4343

4444
$this->assertTrue($result->isAttributeValid('bool'));
4545
$this->assertFalse($result->isAttributeValid('int'));
46-
$this->assertCount(1, $result->getAttributeErrors('int'));
46+
$this->assertCount(2, $result->getAttributeErrors('int'));
4747
}
4848

4949
public function resultDataProvider(): array

tests/Rule/AtLeastTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function optionsProvider(): array
8787
'min' => 1,
8888
'message' => 'The model is not valid. Must have at least "1" filled attributes.',
8989
'skipOnEmpty' => false,
90-
'skipOnError' => true,
90+
'skipOnError' => false,
9191
],
9292
],
9393
[
@@ -96,7 +96,7 @@ public function optionsProvider(): array
9696
'min' => 2,
9797
'message' => 'The model is not valid. Must have at least "2" filled attributes.',
9898
'skipOnEmpty' => false,
99-
'skipOnError' => true,
99+
'skipOnError' => false,
100100
],
101101
],
102102
];

tests/Rule/BooleanTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function optionsProvider(): array
6363
'falseValue' => '0',
6464
'message' => 'The value must be either "1" or "0".',
6565
'skipOnEmpty' => false,
66-
'skipOnError' => true,
66+
'skipOnError' => false,
6767
],
6868
],
6969
[
@@ -74,7 +74,7 @@ public function optionsProvider(): array
7474
'falseValue' => '0',
7575
'message' => 'The value must be either "1" or "0".',
7676
'skipOnEmpty' => true,
77-
'skipOnError' => true,
77+
'skipOnError' => false,
7878
],
7979
],
8080
[
@@ -107,7 +107,7 @@ public function optionsProvider(): array
107107
'falseValue' => '0',
108108
'message' => 'The value must be either "YES" or "0".',
109109
'skipOnEmpty' => false,
110-
'skipOnError' => true,
110+
'skipOnError' => false,
111111
],
112112
],
113113
[
@@ -118,7 +118,7 @@ public function optionsProvider(): array
118118
'falseValue' => 'NO',
119119
'message' => 'The value must be either "1" or "NO".',
120120
'skipOnEmpty' => false,
121-
'skipOnError' => true,
121+
'skipOnError' => false,
122122
],
123123
],
124124
[
@@ -129,7 +129,7 @@ public function optionsProvider(): array
129129
'falseValue' => 'NO',
130130
'message' => 'The value must be either "YES" or "NO".',
131131
'skipOnEmpty' => false,
132-
'skipOnError' => true,
132+
'skipOnError' => false,
133133
],
134134
],
135135
];

tests/Rule/CallbackTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function optionsProvider(): array
5656
}),
5757
[
5858
'skipOnEmpty' => false,
59-
'skipOnError' => true,
59+
'skipOnError' => false,
6060
],
6161
],
6262
[
@@ -65,7 +65,7 @@ public function optionsProvider(): array
6565
})->skipOnEmpty(true),
6666
[
6767
'skipOnEmpty' => true,
68-
'skipOnError' => true,
68+
'skipOnError' => false,
6969
],
7070
],
7171
];

tests/Rule/CompareToTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function optionsProvider(): array
9393
'compareValue' => 1,
9494
'message' => 'Value must be equal to "1".',
9595
'skipOnEmpty' => false,
96-
'skipOnError' => true,
96+
'skipOnError' => false,
9797
],
9898
],
9999
[
@@ -104,7 +104,7 @@ public function optionsProvider(): array
104104
'compareValue' => 1,
105105
'message' => 'Value must be equal to "1".',
106106
'skipOnEmpty' => false,
107-
'skipOnError' => true,
107+
'skipOnError' => false,
108108
],
109109
],
110110
[
@@ -115,7 +115,7 @@ public function optionsProvider(): array
115115
'compareValue' => 1,
116116
'message' => 'Value must be greater than or equal to "1".',
117117
'skipOnEmpty' => false,
118-
'skipOnError' => true,
118+
'skipOnError' => false,
119119
],
120120
],
121121
[
@@ -126,7 +126,7 @@ public function optionsProvider(): array
126126
'compareValue' => 'YES',
127127
'message' => 'Value must be equal to "YES".',
128128
'skipOnEmpty' => false,
129-
'skipOnError' => true,
129+
'skipOnError' => false,
130130
],
131131
],
132132
[
@@ -137,7 +137,7 @@ public function optionsProvider(): array
137137
'compareValue' => 'YES',
138138
'message' => 'Value must be equal to "YES".',
139139
'skipOnEmpty' => true,
140-
'skipOnError' => true,
140+
'skipOnError' => false,
141141
],
142142
],
143143
[
@@ -148,7 +148,7 @@ public function optionsProvider(): array
148148
'compareValue' => 'YES',
149149
'message' => 'Value must not be equal to "YES".',
150150
'skipOnEmpty' => false,
151-
'skipOnError' => true,
151+
'skipOnError' => false,
152152
],
153153
],
154154
[
@@ -159,7 +159,7 @@ public function optionsProvider(): array
159159
'compareValue' => 'YES',
160160
'message' => 'Custom message for YES',
161161
'skipOnEmpty' => false,
162-
'skipOnError' => true,
162+
'skipOnError' => false,
163163
],
164164
],
165165
];

tests/Rule/EachTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testOptions(): void
5252
'max' => 13,
5353
'tooBigMessage' => 'Value must be no greater than 13.',
5454
'skipOnEmpty' => false,
55-
'skipOnError' => true,
55+
'skipOnError' => false,
5656
],
5757
[
5858
'number',
@@ -63,7 +63,7 @@ public function testOptions(): void
6363
'max' => 14,
6464
'tooBigMessage' => 'Value must be no greater than 14.',
6565
'skipOnEmpty' => false,
66-
'skipOnError' => true,
66+
'skipOnError' => false,
6767
],
6868
], Each::rule($ruleSet)->getOptions());
6969
}

tests/Rule/EmailTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function optionsProvider(): array
225225
'enableIDN' => false,
226226
'message' => 'This value is not a valid email address.',
227227
'skipOnEmpty' => false,
228-
'skipOnError' => true,
228+
'skipOnError' => false,
229229
],
230230
],
231231
[
@@ -236,7 +236,7 @@ public function optionsProvider(): array
236236
'enableIDN' => false,
237237
'message' => 'This value is not a valid email address.',
238238
'skipOnEmpty' => false,
239-
'skipOnError' => true,
239+
'skipOnError' => false,
240240
],
241241
],
242242
[
@@ -247,7 +247,7 @@ public function optionsProvider(): array
247247
'enableIDN' => false,
248248
'message' => 'This value is not a valid email address.',
249249
'skipOnEmpty' => false,
250-
'skipOnError' => true,
250+
'skipOnError' => false,
251251
],
252252
],
253253
[
@@ -258,7 +258,7 @@ public function optionsProvider(): array
258258
'enableIDN' => true,
259259
'message' => 'This value is not a valid email address.',
260260
'skipOnEmpty' => false,
261-
'skipOnError' => true,
261+
'skipOnError' => false,
262262
],
263263
],
264264
];

tests/Rule/GroupRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testOptions(): void
4444
'required',
4545
'message' => 'Value cannot be blank.',
4646
'skipOnEmpty' => false,
47-
'skipOnError' => true,
47+
'skipOnError' => false,
4848
],
4949
[
5050
'url',
@@ -53,7 +53,7 @@ public function testOptions(): void
5353
'validSchemes' => ['http', 'https',],
5454
'pattern' => '/^{schemes}:\/\/(([a-zA-Z0-9][a-zA-Z0-9_-]*)(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+)(?::\d{1,5})?([?\/#].*$|$)/',
5555
'skipOnEmpty' => false,
56-
'skipOnError' => true,
56+
'skipOnError' => false,
5757
],
5858
[
5959
'hasLength',
@@ -64,7 +64,7 @@ public function testOptions(): void
6464
'tooLongMessage' => 'This value should contain at most {max, number} {max, plural, one{character} other{characters}}.',
6565
'encoding' => 'UTF-8',
6666
'skipOnEmpty' => false,
67-
'skipOnError' => true,
67+
'skipOnError' => false,
6868
],
6969
], $rule->getOptions());
7070
}

tests/Rule/HasLengthTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function optionsProvider(): array
120120
'tooLongMessage' => 'This value should contain at most {max, number} {max, plural, one{character} other{characters}}.',
121121
'encoding' => 'UTF-8',
122122
'skipOnEmpty' => false,
123-
'skipOnError' => true,
123+
'skipOnError' => false,
124124
],
125125
],
126126
[
@@ -133,7 +133,7 @@ public function optionsProvider(): array
133133
'tooLongMessage' => 'This value should contain at most {max, number} {max, plural, one{character} other{characters}}.',
134134
'encoding' => 'UTF-8',
135135
'skipOnEmpty' => false,
136-
'skipOnError' => true,
136+
'skipOnError' => false,
137137
],
138138
],
139139
[
@@ -146,7 +146,7 @@ public function optionsProvider(): array
146146
'tooLongMessage' => 'This value should contain at most {max, number} {max, plural, one{character} other{characters}}.',
147147
'encoding' => 'UTF-8',
148148
'skipOnEmpty' => false,
149-
'skipOnError' => true,
149+
'skipOnError' => false,
150150
],
151151
],
152152
[
@@ -159,7 +159,7 @@ public function optionsProvider(): array
159159
'tooLongMessage' => 'This value should contain at most {max, number} {max, plural, one{character} other{characters}}.',
160160
'encoding' => 'windows-1251',
161161
'skipOnEmpty' => false,
162-
'skipOnError' => true,
162+
'skipOnError' => false,
163163
],
164164
],
165165
];

0 commit comments

Comments
 (0)