!!!IMPORTANT!!!
The following upgrading instructions are cumulative. That is, if you want to upgrade from version A to version C and there is version B between A and C, you need to follow the instructions for both A and B.
-
Renamed classes/interfaces/traits:
Yiisoft\Validator\AttributeTranslator\ArrayAttributeTranslator
toYiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator
,Yiisoft\Validator\AttributeTranslator\NullAttributeTranslator
toYiisoft\Validator\PropertyTranslator\NullPropertyTranslator
,Yiisoft\Validator\AttributeTranslator\TranslatorAttributeTranslator
toYiisoft\Validator\PropertyTranslator\TranslatorPropertyTranslator
,Yiisoft\Validator\AttributeTranslatorInterface
toYiisoft\Validator\PropertyTranslatorInterface
,Yiisoft\Validator\Rule\AtLeast
toYiisoft\Validator\Rule\FilledAtLeast
,Yiisoft\Validator\Rule\OneOf
toYiisoft\Validator\Rule\FilledOnlyOneOf
.
-
Changed interface
Yiisoft\Validator\AttributeTranslatorProviderInterface
:- renamed to
Yiisoft\Validator\PropertyTranslatorProviderInterface
, - method
getAttributeTranslator()
renamed togetPropertyTranslator()
.
- renamed to
-
Renamed methods in
DataSetInterface
:getAttributeValue()
togetPropertyValue()
,hasAttribute()
tohasProperty()
.
-
Renamed methods in
ObjectParser
:getAttributeValue()
togetPropertyValue()
,hasAttribute()
tohasProperty()
,getAttributeTranslator()
togetPropertyTranslator()
.
-
Renamed methods in
Result
:isAttributeValid()
toisPropertyValid()
,getErrorMessagesIndexedByAttribute()
togetErrorMessagesIndexedByProperty()
,getFirstErrorMessagesIndexedByAttribute()
togetFirstErrorMessagesIndexedByProperty()
,getAttributeErrors()
togetPropertyErrors()
,getAttributeErrorMessages()
togetPropertyErrorMessages()
,getAttributeErrorMessagesIndexedByPath()
togetPropertyErrorMessagesIndexedByPath()
.
-
Renamed methods in
Yiisoft\Validator\ValidationContext
:setAttributeTranslator()
tosetPropertyTranslator()
,getAttribute()
togetProperty()
,setAttribute()
tosetProperty()
,isAttributeMissing()
toisPropertyMissing()
.
-
Renamed rule message placeholders and the corresponding properties/methods of rules:
{attribute}
to{property}
,{targetAttribute}
to{targetProperty}
,{targetAttributeValue}
to{targetPropertyValue}
,{targetValueOrAttribute}
to{targetValueOrProperty}
,{attributes}
to{properties}
.
-
The signature for
Yiisoft\Validator\RuleHandlerInterface::validate()
changed. If you have classes that implementRuleHandlerInterface
, change the type of$rule
parameter in methodvalidate()
fromobject
toRuleInterface
. For example:use Yiisoft\Validator\ValidationContext; public function validate(mixed $value, object $rule, ValidationContext $context): Result;
Change to:
use Yiisoft\Validator\RuleInterface; use Yiisoft\Validator\ValidationContext; public function validate(mixed $value, RuleInterface $rule, ValidationContext $context): Result;
-
The type of
$escape
argument inYiisoft\Validator\Error::getValuePath()
changed frombool|string|null
tostring|null
. If you usedbool
, replacefalse
withnull
andtrue
with dot (.
). -
For custom rules using
Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait
, apply the following changes for$skipOnEmpty
property in the constructor:- Turn in it into argument (remove
private
visibility). - Change type from
mixed
to more specificbool|callable|null
- Add manual initialization of property value.
For example:
public function __construct( // ... private mixed $skipOnEmpty = null, // ... ) { // ... }
Change to:
public function __construct( // ... bool|callable|null $skipOnEmpty = null, // ... ) { $this->skipOnEmpty = $skipOnEmpty; }
- Turn in it into argument (remove