You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extra documentation for most common support issues
Message translation approaches
Navigating the messages tree manually
Using validators with custom names
Expressing boolean algebra
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.
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, newDomainException('Customers must have valid emails'));
v::email()->assert($input, newDomainException('Customers must have valid emails'));
The text was updated successfully, but these errors were encountered:
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
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:The text was updated successfully, but these errors were encountered: