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

Fix all known issues + inconsistencies #12

Closed
wants to merge 7 commits into from
Closed

Fix all known issues + inconsistencies #12

wants to merge 7 commits into from

Conversation

mychidarko
Copy link
Member

What kind of change does this PR introduce? (pls check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe below

Description

This update makes a few changes that require a new major version in order to not mess up the flow of existing applications. We however believe that the changes are necessary. They are all detailed below:

  • Changes to the way arrays are validated. The previous version had an array() rule which was considered a "special rule" different from the way all other rules were validated. This had some problems like performance issues and also errors when using complex validators like min:x together with array(). There were also issues when combining multiple validators together with array() eg: array(string|numeric) which would accept ['123'] but this failed. array() is replaced by the array rule in this version which is a real rule but can also be extended to validate items in an array like array<numeric|string>. Unlike the previous version, this also works with complex validators: array<string|min:3|between:[2,5]>

  • Fixed inconsistencies in validation. Internally, there were some issues that led to validators being inefficient and/or insecure (of course, other parts of Leaf covered up the vulnerabilities). This version removes all those weak links and makes validation more consistent between functions

  • Fixed breaks when chaining complex validators as strings. There was an issue where chaining complex validators like min:x and contains:x as strings could break the validation flow, this was also the case with array and |. Basically, all those issues have been fixed now.

  • Every item that should be validated is required by default. Before we had the opposite flow where every item was optional by default, so you needed to add required. This was quite clumsy because more often than not, people validate required fields. This update corrects that behaviour and offers an optional rule for fields that can be empty or nullable.

  • Additional petty fixes have been made to validators that did not work as expected in the previous version. An example is the in validator which just did not work right depending on the condition. This and other validators have been fixed in this version.

The release will be tagged as v3 since it breaks a lot of flows from the previous version, especially the default required change.

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Related Issue

#11

@mychidarko mychidarko marked this pull request as draft November 2, 2024 12:36
@mychidarko mychidarko marked this pull request as ready for review November 4, 2024 20:06
@mychidarko
Copy link
Member Author

Closing this as merged (v3.x) in order to preserve the v2.x branch

@mychidarko mychidarko closed this Nov 4, 2024
@mychidarko mychidarko deleted the next branch November 4, 2024 20:18
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.

1 participant