-
Notifications
You must be signed in to change notification settings - Fork 777
Open
Labels
Milestone
Description
To-dos
I'm almost there, and there are some awesome improvements coming!
Core
- Improve array messages
- Create
Validator::validate()
that returns an object with errors - ? Rename
Result->isValid
toResult->hasPassed
- Create transformer to deal with composite rules with a single argument
- Make
Simple::isValid
public - Use paths to identify when a rule fails
- Create
{{placeholder|quote}}
- Create custom Stringifier, removing CallableStringifier
- Replace
setName()
withNamed
rule - Get ignored paths for ValidationException from ValidatorDefaults
- Replace
setTemplate()
withTemplated
rule -
Create class alias for old abstract classes - Rename mode "negative" to "inverted"
- Add second parameter to
Validator::assert()
- Create "key" prefix
- Create "length" prefix
- Create "max" prefix
- Create "min" prefix
- Create "nullOr" prefix
- Create "property" prefix
- Create "undefOr" prefix
- Make
ComponentException
extendLogicException
- Make
getMessages()
return__self__
- Make
setName()
update names, but not IDs - Prefix ids when working with sibling results
- Update validation engine (todo: split into different tasks)
- Use PHP Attributes to define templates
Rules
- Create
Masked
rule -- which allows masking the input - Promote
Reducer
to an actual rule - Enable
Attributes
to deal with inheritance - Allow to use certain rules as class attributes
- Rename "Consecutive" to something shorter
- Only create
Max
with subsequents when possible - Only create
Min
with subsequents when possible - Only create
Length
with subsequents when possible - Add support to PHP 8.4
- Update
DateTimeDiff
to generate results with subsequents - Tentatively created a result with subsequents in
UndefOr
andNullOr
- Refactor
KeySet
rule - Create
DateDiff
rule - Delete
MinAge
,MaxAge
, andAge
rules - Rename
NotOptional
toNotUndef
- Create
BetweenExclusive
rule - Create
Consecutive
rule - Create
LazySequence
rule - Create a new
Max
rule - Create a new
Min
rule - Create aliases for deprecated/removed rules
- Delete
KeyValue
rule - Do not use When as a sibling
- Refactor
Length
rule - Rename
Nullable
toNullOr
- Rename
Optional
toUndefOr
- Rename
Max
rule toLessThanOrEqual
- Rename
Min
rule toGreaterThanOrEqual
- Rename the "Attribute" rule to "Property"
- Split the
Key
rule intoKey
,KeyExists
, andKeyOptional
- Split the
Property
rule intoProperty
,PropertyExists
, andPropertyOptional
Other
- Make documentation up to date with the changes
- Write a blog post with the latest changes
- Improve documentation for rules that are prefixes
- Release version 2.4 with deprecations
- Fix broken documentation links
- Rename branch
master
tomain
Nice to have
- [ ] More integration tests for `oneOf`, `allOf` and `each` validator messages.
- [ ] Create `All` rule (similar to `Each` but creates results with subsequents)
- [ ] Create `DateTimeParseable` or (`DateTimeLenient`) rule
- [ ] Increase code coverage to 98%
- [ ] Share credentials for @TheRespectPanda with @alganet
- [ ] Extra documentation for most common support issues
- [ ] Message translation approaches
- [ ] Navigating the messages tree manually
- [ ] Using validators with custom names
- [ ] Expressing boolean algebra
Update validation engine
Here are some "problems" I see with the current engine
- Allowing each rule to execute
assert()
andcheck()
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()
will be available only on Validator
, you could do things like that:
// Passing the template as a string
v::email()->assert($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()->assert($input, new DomainException('Customers must have valid emails'));
// Passing a custom callable
v::email()->assert($input, fn($exception) => new DomainException('Something failed: ' . $exception->getMessage());
russelomua, andus4n, wmendes-ionos and alganet