-
Notifications
You must be signed in to change notification settings - Fork 776
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->isValidtoResult->hasPassed - Create transformer to deal with composite rules with a single argument
- Make
Simple::isValidpublic - Use paths to identify when a rule fails
- Create
{{placeholder|quote}} - Create custom Stringifier, removing CallableStringifier
- Replace
setName()withNamedrule - Get ignored paths for ValidationException from ValidatorDefaults
- Replace
setTemplate()withTemplatedrule -
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
ComponentExceptionextendLogicException - 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
Maskedrule -- which allows masking the input - Promote
Reducerto an actual rule - Enable
Attributesto deal with inheritance - Allow to use certain rules as class attributes
- Rename "Consecutive" to something shorter
- Only create
Maxwith subsequents when possible - Only create
Minwith subsequents when possible - Only create
Lengthwith subsequents when possible - Add support to PHP 8.4
- Update
DateTimeDiffto generate results with subsequents - Tentatively created a result with subsequents in
UndefOrandNullOr - Refactor
KeySetrule - Create
DateDiffrule - Delete
MinAge,MaxAge, andAgerules - Rename
NotOptionaltoNotUndef - Create
BetweenExclusiverule - Create
Consecutiverule - Create
LazySequencerule - Create a new
Maxrule - Create a new
Minrule - Create aliases for deprecated/removed rules
- Delete
KeyValuerule - Do not use When as a sibling
- Refactor
Lengthrule - Rename
NullabletoNullOr - Rename
OptionaltoUndefOr - Rename
Maxrule toLessThanOrEqual - Rename
Minrule toGreaterThanOrEqual - Rename the "Attribute" rule to "Property"
- Split the
Keyrule intoKey,KeyExists, andKeyOptional - Split the
Propertyrule 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
mastertomain
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