Skip to content

Commit 6022914

Browse files
committed
Remove Yes and No rules
I created those validators to make it easy to parse parameters or console command inputs that were answers to questions one might ask. One of the biggest problems is that it depends on the machine's locale, which can be a bit troublesome, rather than receiving a locale in the constructor. That doesn’t allow for a lot of flexibility when someone has a multi-lingual application. Additionally, these validators rely on the regex from `nl_langinfo()`, which is very permissive, resulting in false positives. I have a working version of a console command that retrieves data from the Unicode Common Locale Data Repository (CLDR) and updates a list of `yesstr` and `nostr` strings from the main XML file of each language. However, I came to realise that the whole thing is not worth it. The validators Yes and No can be replaced by using rules like `Regex` and `In`. They won’t have the ease of multilingual support, but I don’t think those validators are used a lot. So, I decided I would just remove them, and if users really ask for it in the next major version, I’d be happy to revive my branch.
1 parent 35ea95c commit 6022914

26 files changed

Lines changed: 0 additions & 596 deletions

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ jobs:
3131
php-version: ${{ matrix.php-version }}
3232
coverage: none
3333

34-
- name: Install Localisation Files
35-
run: |
36-
sudo locale-gen --no-purge --lang nl_NL.UTF-8
37-
sudo locale-gen --no-purge --lang pt_BR.UTF-8
38-
sudo locale-gen --no-purge --lang ru_RU.UTF-8
39-
4034
- name: Install Dependencies
4135
run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }}
4236

@@ -61,12 +55,6 @@ jobs:
6155
php-version: 8.5
6256
coverage: pcov
6357

64-
- name: Install Localisation Files
65-
run: |
66-
sudo locale-gen --no-purge --lang nl_NL.UTF-8
67-
sudo locale-gen --no-purge --lang pt_BR.UTF-8
68-
sudo locale-gen --no-purge --lang ru_RU.UTF-8
69-
7058
- name: Install Dependencies
7159
run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }}
7260

docs/list-of-validators-by-category.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
- [BoolType](validators/BoolType.md)
3131
- [BoolVal](validators/BoolVal.md)
3232
- [FalseVal](validators/FalseVal.md)
33-
- [No](validators/No.md)
3433
- [TrueVal](validators/TrueVal.md)
35-
- [Yes](validators/Yes.md)
3634

3735
## Callables
3836

@@ -406,7 +404,6 @@
406404
- [NfeAccessKey](validators/NfeAccessKey.md)
407405
- [Nif](validators/Nif.md)
408406
- [Nip](validators/Nip.md)
409-
- [No](validators/No.md)
410407
- [NoneOf](validators/NoneOf.md)
411408
- [Not](validators/Not.md)
412409
- [NullOr](validators/NullOr.md)
@@ -466,4 +463,3 @@
466463
- [When](validators/When.md)
467464
- [Writable](validators/Writable.md)
468465
- [Xdigit](validators/Xdigit.md)
469-
- [Yes](validators/Yes.md)

docs/validators/BoolType.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ See also:
4646
- [FloatType](FloatType.md)
4747
- [FloatVal](FloatVal.md)
4848
- [IntType](IntType.md)
49-
- [No](No.md)
5049
- [NullType](NullType.md)
5150
- [Number](Number.md)
5251
- [ObjectType](ObjectType.md)
@@ -55,4 +54,3 @@ See also:
5554
- [StringVal](StringVal.md)
5655
- [TrueVal](TrueVal.md)
5756
- [Type](Type.md)
58-
- [Yes](Yes.md)

docs/validators/BoolVal.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ See also:
4848
- [FloatType](FloatType.md)
4949
- [FloatVal](FloatVal.md)
5050
- [IntType](IntType.md)
51-
- [No](No.md)
5251
- [NullType](NullType.md)
5352
- [ObjectType](ObjectType.md)
5453
- [ResourceType](ResourceType.md)
5554
- [StringType](StringType.md)
5655
- [TrueVal](TrueVal.md)
5756
- [Type](Type.md)
58-
- [Yes](Yes.md)

docs/validators/No.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

docs/validators/Yes.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

library/Mixins/AllBuilder.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ public static function allNif(): Chain;
217217

218218
public static function allNip(): Chain;
219219

220-
public static function allNo(bool $useLocale = false): Chain;
221-
222220
public static function allNoneOf(Validator $validator1, Validator $validator2, Validator ...$validators): Chain;
223221

224222
public static function allNot(Validator $validator): Chain;
@@ -324,6 +322,4 @@ public static function allWhen(Validator $when, Validator $then, Validator|null
324322
public static function allWritable(): Chain;
325323

326324
public static function allXdigit(string ...$additionalChars): Chain;
327-
328-
public static function allYes(bool $useLocale = false): Chain;
329325
}

library/Mixins/AllChain.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ public function allNif(): Chain;
217217

218218
public function allNip(): Chain;
219219

220-
public function allNo(bool $useLocale = false): Chain;
221-
222220
public function allNoneOf(Validator $validator1, Validator $validator2, Validator ...$validators): Chain;
223221

224222
public function allNot(Validator $validator): Chain;
@@ -324,6 +322,4 @@ public function allWhen(Validator $when, Validator $then, Validator|null $else =
324322
public function allWritable(): Chain;
325323

326324
public function allXdigit(string ...$additionalChars): Chain;
327-
328-
public function allYes(bool $useLocale = false): Chain;
329325
}

library/Mixins/Builder.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ public static function nif(): Chain;
243243

244244
public static function nip(): Chain;
245245

246-
public static function no(bool $useLocale = false): Chain;
247-
248246
public static function noneOf(Validator $validator1, Validator $validator2, Validator ...$validators): Chain;
249247

250248
public static function not(Validator $validator): Chain;
@@ -363,6 +361,4 @@ public static function when(Validator $when, Validator $then, Validator|null $el
363361
public static function writable(): Chain;
364362

365363
public static function xdigit(string ...$additionalChars): Chain;
366-
367-
public static function yes(bool $useLocale = false): Chain;
368364
}

library/Mixins/Chain.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ public function nif(): Chain;
246246

247247
public function nip(): Chain;
248248

249-
public function no(bool $useLocale = false): Chain;
250-
251249
public function noneOf(Validator $validator1, Validator $validator2, Validator ...$validators): Chain;
252250

253251
public function not(Validator $validator): Chain;
@@ -366,6 +364,4 @@ public function when(Validator $when, Validator $then, Validator|null $else = nu
366364
public function writable(): Chain;
367365

368366
public function xdigit(string ...$additionalChars): Chain;
369-
370-
public function yes(bool $useLocale = false): Chain;
371367
}

0 commit comments

Comments
 (0)