Remove Yes and No rules#1598
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1598 +/- ##
============================================
- Coverage 97.44% 97.43% -0.02%
+ Complexity 988 981 -7
============================================
Files 213 211 -2
Lines 2273 2259 -14
============================================
- Hits 2215 2201 -14
Misses 58 58 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request removes the Yes and No validators from the validation library due to their reliance on locale-dependent behavior that is problematic and hard to maintain. The validators depended on nl_langinfo() with locale constants which were overly permissive and caused false positives.
Changes:
- Removed
YesandNovalidator classes and their associated tests - Removed documentation for the removed validators and updated references in related docs
- Cleaned up CI workflow by removing locale generation steps that were only needed for these validators
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| library/Validators/Yes.php | Deleted Yes validator implementation |
| library/Validators/No.php | Deleted No validator implementation |
| tests/unit/Validators/YesTest.php | Deleted unit tests for Yes validator |
| tests/unit/Validators/NoTest.php | Deleted unit tests for No validator |
| tests/feature/Validators/YesTest.php | Deleted feature tests for Yes validator |
| tests/feature/Validators/NoTest.php | Deleted feature tests for No validator |
| library/Mixins/*.php | Removed yes() and no() method declarations from all mixin interfaces (Chain, Builder, and their variants) |
| docs/validators/Yes.md | Deleted documentation for Yes validator |
| docs/validators/No.md | Deleted documentation for No validator |
| docs/validators/BoolVal.md | Removed references to Yes and No validators from "See also" section |
| docs/validators/BoolType.md | Removed references to Yes and No validators from "See also" section |
| docs/list-of-validators-by-category.md | Removed Yes and No from both categorical and alphabetical validator lists |
| .github/workflows/continuous-integration.yml | Removed locale generation steps (nl_NL, pt_BR, ru_RU) that were only needed for Yes/No validator tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
yesstrandnostrstrings 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
RegexandIn. 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.