!!!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\ArrayAttributeTranslatortoYiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator,Yiisoft\Validator\AttributeTranslator\NullAttributeTranslatortoYiisoft\Validator\PropertyTranslator\NullPropertyTranslator,Yiisoft\Validator\AttributeTranslator\TranslatorAttributeTranslatortoYiisoft\Validator\PropertyTranslator\TranslatorPropertyTranslator,Yiisoft\Validator\AttributeTranslatorInterfacetoYiisoft\Validator\PropertyTranslatorInterface,Yiisoft\Validator\Rule\AtLeasttoYiisoft\Validator\Rule\FilledAtLeast,Yiisoft\Validator\Rule\OneOftoYiisoft\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$ruleparameter in methodvalidate()fromobjecttoRuleInterface. 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
$escapeargument inYiisoft\Validator\Error::getValuePath()changed frombool|string|nulltostring|null. If you usedbool, replacefalsewithnullandtruewith dot (.). -
For custom rules using
Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait, apply the following changes for$skipOnEmptyproperty in the constructor:- Turn in it into argument (remove
privatevisibility). - Change type from
mixedto 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