NOTE: I will be away until mid-April. Things are very busy at work at the moment, so I will have to pause working in this release for a little while.
To-dos
Rules
[ ] Create All rule (similar to Each but creates results with siblings)
[ ] Create DateDiff rule
[ ] Create DateTimeParseable or (DateTimeLenient) rule
[ ] Delete MinAge, MaxAge, and Age rules
[ ] Refactor KeySet rule
[ ] Tentatively created a result with siblings in UndefOr and NullOr
[ ] Do not allow rules with children to be used as sibling
[x] Rename NotOptional to NotUndef
[x] Create BetweenExclusive rule
[x] Create Consecutive rule
[x] Create LazySequence rule
[x] Create a new Max rule
[x] Create a new Min rule
[x] Create aliases for deprecated/removed rules
[x] Delete KeyValue rule
[x] Do not use When as a sibling
[x] Refactor Length rule
[x] Rename Nullable to NullOr
[x] Rename Optional to UndefOr
[x] Rename Max rule to LessThanOrEqual
[x] Rename Min rule to GreaterThanOrEqual
[x] Rename the "Attribute" rule to "Property"
[x] Split the Key rule into Key, KeyExists, and KeyOptional
[x] Split the Property rule into Property, PropertyExists, and PropertyOptional
Core
[ ] Create class alias for old abstract classes
[ ] More integration tests for oneOf, allOf and each validator messages.
[ ] Rename mode "negative" to "inverted"
[ ] Create "all" prefix
[x] Add second parameter to Validator::assert()
[x] Create "key" prefix
[x] Create "length" prefix
[x] Create "max" prefix
[x] Create "min" prefix
[x] Create "nullOr" prefix
[x] Create "property" prefix
[x] Create "undefOr" prefix
[x] Make ComponentException extend LogicException
[x] Make getMessages() return __self__
[x] Make setName() update names, but not IDs
[x] Prefix ids when working with sibling results
[x] Update validation engine (todo: split into different tasks)
[x] Use PHP Attributes to define templates
Other
[ ] Increase code coverage to 98%
[ ] Get my credentials for @TheRespectPanda accounts in order
[ ] Fix broken documentation links
[ ] Extra documentation for most common support issues
[ ] Message translation approaches
[ ] Navigating the messages tree manually
[ ] Using validators with custom names
[ ] Expressing boolean algebra
[x] Rename branch master to main
Update validation engine
Here are some "problems" I see with the current engine
Allowing each rule to execute assert() and check() means duplication in some cases.
Because we use exceptions to assert/check, we can only invert a validation (with Not) if there are errors. That means that we have limited granularity control.
There is a lot of logic in the exceptions. That means that even after an exception is thrown, something could still happen. We're stable on that front, but I want to simplify them. Besides, debugging exception code is painful because the stack track stops once the exception constructor is created.
On version 3.0, this won't be possible anymore:
$email = new Email():
$email->assert($input);
Instead, you would need to do that:
$validator = new Validator(new Email());
$validator->assert($input);
However, because assert() and check() will be available only on Validator, you could do things like that:
// Passing the template as a string
v::email()->check($input, 'Uff... {{input}} should have been an email');
// Passing an array of templates
v::intValue()->positive()->lessThan(5)->assert($input, [
'intValue' => 'Area must be an integer',
'positive' => 'Area must be a positive number',
'lessThan' => 'Area cannot be bigger than m2',
]);
// Passing a custom exception
v::email()->check($input, new DomainException('Customers must have valid emails'));
v::email()->assert($input, new DomainException('Customers must have valid emails'));
NOTE: I will be away until mid-April. Things are very busy at work at the moment, so I will have to pause working in this release for a little while.
To-dos
Rules
All
rule (similar toEach
but creates results with siblings)DateDiff
ruleDateTimeParseable
or (DateTimeLenient
) ruleMinAge
,MaxAge
, andAge
rulesKeySet
ruleUndefOr
andNullOr
NotOptional
toNotUndef
BetweenExclusive
ruleConsecutive
ruleLazySequence
ruleMax
ruleMin
ruleKeyValue
ruleLength
ruleNullable
toNullOr
Optional
toUndefOr
Max
rule toLessThanOrEqual
Min
rule toGreaterThanOrEqual
Key
rule intoKey
,KeyExists
, andKeyOptional
Property
rule intoProperty
,PropertyExists
, andPropertyOptional
Core
oneOf
,allOf
andeach
validator messages.Validator::assert()
ComponentException
extendLogicException
getMessages()
return__self__
setName()
update names, but not IDsOther
[x] Rename branch
master
tomain
Update validation engine
Here are some "problems" I see with the current engine
assert()
andcheck()
means duplication in some cases.Not
) if there are errors. That means that we have limited granularity control.On version 3.0, this won't be possible anymore:
Instead, you would need to do that:
However, because
assert()
andcheck()
will be available only onValidator
, you could do things like that: