π permitir
v3.0 - 7 Nov 2024
Added
- Added new validators like
truefalse,numeric,floatandhardfloat
Fixed
-
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:xandcontains:xas strings could break the validation flow, this was also the case with array and |. Basically, all those issues have been fixed now. -
Additional petty fixes have been made to validators that did not work as expected
inthe 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.
Changed
-
Every item that should be validated is required by default. v2.x 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 anoptionalrule for fields that can be empty or nullable. -
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 should 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 likearray<numeric|string>. Unlike the previous version, this also works with complex validators:array<string|min:3|between:[2,5]>
Removed
- As explained,
array()has been replaced byarray<> test()has been replaced byvalidateRule()