diff --git a/CHANGELOG.md b/CHANGELOG.md index 185b40830..f80b8abc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 2.0.0 under development +- Chg #694: Rename `AtLeast` rule to `FilledAtLeast` and `OneOf` rule to `FilledOnlyOneOf` (@arogachev) - Enh #492: Add type to error messages related with incorrect input (@arogachev) - Enh #735: Make `Json::$message` a bit more clear (@arogachev) - Bug #736: Fix wrong value for `type` parameter for `Each::$incorrectInputKeyMessage` (@arogachev) diff --git a/README.md b/README.md index 29276677e..482ce8a04 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,14 @@ composer require yiisoft/validator Validator allows to check data in any format. For example, when data is an object: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; use Yiisoft\Validator\Rule\Number; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Validator; -#[AtLeast(['email', 'phone'])] +#[FilledAtLeast(['email', 'phone'])] final class Person { public function __construct( diff --git a/UPGRADE.md b/UPGRADE.md index 6f0a3587d..e891e2d82 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -13,7 +13,9 @@ for both A and B. - `Yiisoft\Validator\AttributeTranslator\ArrayAttributeTranslator` to `Yiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator`, - `Yiisoft\Validator\AttributeTranslator\NullAttributeTranslator` to `Yiisoft\Validator\PropertyTranslator\NullPropertyTranslator`, - `Yiisoft\Validator\AttributeTranslator\TranslatorAttributeTranslator` to `Yiisoft\Validator\PropertyTranslator\TranslatorPropertyTranslator`, - - `Yiisoft\Validator\AttributeTranslatorInterface` to `Yiisoft\Validator\PropertyTranslatorInterface`. + - `Yiisoft\Validator\AttributeTranslatorInterface` to `Yiisoft\Validator\PropertyTranslatorInterface`, + - `Yiisoft\Validator\Rule\AtLeast` to `Yiisoft\Validator\Rule\FilledAtLeast`, + - `Yiisoft\Validator\Rule\OneOf` to `Yiisoft\Validator\Rule\FilledOnlyOneOf`. * Changed interface `Yiisoft\Validator\AttributeTranslatorProviderInterface`: - renamed to `Yiisoft\Validator\PropertyTranslatorProviderInterface`, diff --git a/docs/guide/en/built-in-rules.md b/docs/guide/en/built-in-rules.md index 52b182b63..7a8ad52ad 100644 --- a/docs/guide/en/built-in-rules.md +++ b/docs/guide/en/built-in-rules.md @@ -50,9 +50,9 @@ Here is a list of all available built-in rules, divided by category. ### Count rules -- [AtLeast](../../../src/Rule/AtLeast.php) - [Count](../../../src/Rule/Count.php) -- [OneOf](../../../src/Rule/OneOf.php) +- [FilledAtLeast](../../../src/Rule/FilledAtLeast.php) +- [FilledOnlyOneOf](../../../src/Rule/FilledOnlyOneOf.php) ### File rules diff --git a/docs/guide/en/using-validator.md b/docs/guide/en/using-validator.md index 92a507360..7f3ede03c 100644 --- a/docs/guide/en/using-validator.md +++ b/docs/guide/en/using-validator.md @@ -28,7 +28,7 @@ $result = (new Validator())->validate($value, $rules); It's possible to validate an array both as a whole and by individual items. For example: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Count; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; @@ -46,7 +46,7 @@ $rules = [ // The rules that are not related to a specific property // At least one of the properties ("email" and "phone") must be passed and have non-empty value. - new AtLeast(['email', 'phone']), + new FilledAtLeast(['email', 'phone']), // The rules related to a specific property. @@ -72,14 +72,14 @@ For objects there is an additional option to configure validation with PHP attri separately in explicit way (passing just the object itself is enough). For example: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; use Yiisoft\Validator\Rule\Number; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Validator; -#[AtLeast(['email', 'phone'])] +#[FilledAtLeast(['email', 'phone'])] final class Person { public function __construct( diff --git a/docs/guide/pt-BR/built-in-rules.md b/docs/guide/pt-BR/built-in-rules.md index ffc379360..e3cd94164 100644 --- a/docs/guide/pt-BR/built-in-rules.md +++ b/docs/guide/pt-BR/built-in-rules.md @@ -49,9 +49,9 @@ Aqui está uma lista de todas as regras integradas disponíveis, divididas por c ### Regras de contagem -- [AtLeast](../../../src/Rule/AtLeast.php) - [Count](../../../src/Rule/Count.php) -- [OneOf](../../../src/Rule/OneOf.php) +- [FilledAtLeast](../../../src/Rule/FilledAtLeast.php) +- [FilledOnlyOneOf](../../../src/Rule/FilledOnlyOneOf.php) ### Regras de arquivo diff --git a/docs/guide/pt-BR/using-validator.md b/docs/guide/pt-BR/using-validator.md index 2b0027448..eae737d23 100644 --- a/docs/guide/pt-BR/using-validator.md +++ b/docs/guide/pt-BR/using-validator.md @@ -28,7 +28,7 @@ $result = (new Validator())->validate($value, $rules); É possível validar um array como um todo ou por itens individuais. Por exemplo: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Count; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; @@ -46,7 +46,7 @@ $rules = [ // As regras que não estão relacionadas a um atributo específico // Pelo menos um dos atributos ("email" e "phone") deve ser passado e ter valor não vazio. - new AtLeast(['email', 'phone']), + new FilledAtLeast(['email', 'phone']), // As regras relacionadas a um atributo específico. @@ -72,14 +72,14 @@ Para objetos existe uma opção adicional para configurar a validação com atri separadamente de forma explícita (passar apenas o objeto em si é suficiente). Por exemplo: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; use Yiisoft\Validator\Rule\Number; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Validator; -#[AtLeast(['email', 'phone'])] +#[FilledAtLeast(['email', 'phone'])] final class Person { public function __construct( diff --git a/docs/guide/ru/using-validator.md b/docs/guide/ru/using-validator.md index 36002c42c..faab246f4 100644 --- a/docs/guide/ru/using-validator.md +++ b/docs/guide/ru/using-validator.md @@ -28,7 +28,7 @@ $result = (new Validator())->validate($value, $rules); Валидировать массив можно как целиком, так и по отдельным элементам. Например: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Count; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; @@ -46,7 +46,7 @@ $rules = [ // Правила, не относящиеся к конкретному свойству. // Хотя бы одно из свойств ("email" или "phone"), должен быть передан и иметь непустое значение. - new AtLeast(['email', 'phone']), + new FilledAtLeast(['email', 'phone']), // Правила, относящиеся к конкретному свойству. @@ -71,14 +71,14 @@ $result = (new Validator())->validate($data, $rules); Для объектов есть дополнительная возможность настроить валидацию по атрибутами, что позволяет не передавать правила отдельно явным образом (достаточно передавать только сам объект). Например: ```php -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\Email; use Yiisoft\Validator\Rule\Length; use Yiisoft\Validator\Rule\Number; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Validator; -#[AtLeast(['email', 'phone'])] +#[FilledAtLeast(['email', 'phone'])] final class Person { public function __construct( diff --git a/messages/de/yii-validator.php b/messages/de/yii-validator.php index a01c888eb..b13701f9b 100644 --- a/messages/de/yii-validator.php +++ b/messages/de/yii-validator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Compare; use Yiisoft\Validator\Rule\Count; @@ -21,7 +21,7 @@ use Yiisoft\Validator\Rule\Nested; use Yiisoft\Validator\Rule\NotEqual; use Yiisoft\Validator\Rule\Number; -use Yiisoft\Validator\Rule\OneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; use Yiisoft\Validator\Rule\Regex; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Rule\Subset; @@ -31,7 +31,7 @@ return [ // Used in single rule - /** @see AtLeast */ + /** @see FilledAtLeast */ 'At least {min, number} {min, plural, one{property} other{properties}} from this list must be filled' => 'Mindestens {min, number} {min, plural, one{Attribut aus dieser Liste muss} other{Attribute aus dieser ' . 'Liste müssen}} ausgefüllt werden', @@ -82,7 +82,7 @@ 'Property "{path}" is not found.' => 'Eigenschaft "{path}" nicht gefunden.', /** @see Number */ '{Property} must be a number.' => '{Property} muss eine Nummer sein.', - /** @see OneOf */ + /** @see FilledOnlyOneOf */ 'Exactly 1 property from this list must be filled: {properties}.' => 'Exakt ein Attribut aus dieser Liste ' . 'muss gefüllt sein: {properties}.', /** @see Regex */ @@ -101,9 +101,9 @@ // Used in multiple rules /** - * @see AtLeast + * @see FilledAtLeast * @see Nested - * @see OneOf + * @see FilledOnlyOneOf */ '{Property} must be an array or an object.' => '{Property} muss ein Array oder Object sein.', /** diff --git a/messages/pl/yii-validator.php b/messages/pl/yii-validator.php index 872a5a54a..3a69d55e9 100644 --- a/messages/pl/yii-validator.php +++ b/messages/pl/yii-validator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Compare; use Yiisoft\Validator\Rule\Count; @@ -21,7 +21,7 @@ use Yiisoft\Validator\Rule\Nested; use Yiisoft\Validator\Rule\NotEqual; use Yiisoft\Validator\Rule\Number; -use Yiisoft\Validator\Rule\OneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; use Yiisoft\Validator\Rule\Regex; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Rule\Subset; @@ -31,7 +31,7 @@ return [ // Used in single rule - /** @see AtLeast */ + /** @see FilledAtLeast */ 'At least {min, number} {min, plural, one{property} other{properties}} from this list must be filled' => 'At least {min, number} {min, plural, one{property} other{properties}} from this list must be filled', /** @see BooleanValue */ '{Property} must be either "{true}" or "{false}".' => '{Property} wynosić "{true}" albo "{false}".', @@ -69,7 +69,7 @@ 'Property "{path}" is not found.' => 'Właściwość "{path}" nie została znaleziona.', /** @see Number */ '{Property} must be a number.' => '{Property} być liczbą.', - /** @see OneOf */ + /** @see FilledOnlyOneOf */ 'Exactly 1 property from this list must be filled: {properties}.' => 'Exactly 1 property from this list must be filled: {properties}.', /** @see Regex */ '{Property} is invalid.' => 'Wartość jest nieprawidłowa.', @@ -87,9 +87,9 @@ // Used in multiple rules /** - * @see AtLeast + * @see FilledAtLeast * @see Nested - * @see OneOf + * @see FilledOnlyOneOf */ '{Property} must be an array or an object.' => '{Property} być tablicą lub obiektem.', /** diff --git a/messages/pt-BR/yii-validator.php b/messages/pt-BR/yii-validator.php index 34d8c9ee4..b27f6235e 100644 --- a/messages/pt-BR/yii-validator.php +++ b/messages/pt-BR/yii-validator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Compare; use Yiisoft\Validator\Rule\Count; @@ -21,7 +21,7 @@ use Yiisoft\Validator\Rule\Nested; use Yiisoft\Validator\Rule\NotEqual; use Yiisoft\Validator\Rule\Number; -use Yiisoft\Validator\Rule\OneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; use Yiisoft\Validator\Rule\Regex; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Rule\Subset; @@ -31,7 +31,7 @@ return [ // Usado em regra única - /** @see AtLeast */ + /** @see FilledAtLeast */ 'The data must have at least "{min}" filled properties.' => 'Os dados devem conter no mínimo {min, number} {min, plural, one{atributo preenchido} few{atributo preenchido} many{atributos preenchidos} other{atributo preenchido}}.', /** @see BooleanValue */ 'Value must be either "{true}" or "{false}".' => 'O valor deve ser "{true}" ou "{false}".', @@ -69,7 +69,7 @@ 'Property "{path}" is not found.' => 'Propriedade "{path}" não encontrada.', /** @see Number */ 'Value must be a number.' => 'O valor deve ser um número.', - /** @see OneOf */ + /** @see FilledOnlyOneOf */ 'The data must have at least 1 filled property.' => 'Os dados devem conter pelo menos 1 atributo preenchido.', /** @see Regex */ 'Value is invalid.' => 'O valor está incorreto.', @@ -87,9 +87,9 @@ // Usado em múltiplas regras /** - * @see AtLeast + * @see FilledAtLeast * @see Nested - * @see OneOf + * @see FilledOnlyOneOf */ 'The value must be an array or an object.' => 'O valor deve ser um array ou um objeto.', /** diff --git a/messages/ru/yii-validator.php b/messages/ru/yii-validator.php index e29998c0d..c0d775d76 100644 --- a/messages/ru/yii-validator.php +++ b/messages/ru/yii-validator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Compare; use Yiisoft\Validator\Rule\Count; @@ -22,7 +22,7 @@ use Yiisoft\Validator\Rule\Nested; use Yiisoft\Validator\Rule\NotEqual; use Yiisoft\Validator\Rule\Number; -use Yiisoft\Validator\Rule\OneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; use Yiisoft\Validator\Rule\Regex; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Rule\Subset; @@ -36,7 +36,7 @@ return [ // Used in single rule - /** @see AtLeast */ + /** @see FilledAtLeast */ 'At least {min, number} {min, plural, one{property} other{properties}} from this list must be filled for {property}: {properties}' => 'Как минимум {min, number} {min, plural, one{свойство} few{свойства} many{свойства} other{свойства}} из этого списка {min, plural, one{должен} few{должны} many{должны} other{должны}} быть заполнены для {property}: {properties}.', /** @see BooleanValue */ @@ -83,7 +83,7 @@ 'Property "{path}" is not found in {property}.' => 'Свойство «{path}» не найдено в {property}.', /** @see Number */ '{Property} must be a number.' => '{Property} должно быть числом.', - /** @see OneOf */ + /** @see FilledOnlyOneOf */ 'Exactly 1 property from this list must be filled for {property}: {properties}.' => 'Ровно 1 свойство из этого списка должно быть заполнено в {property}: {properties}.', /** @see Regex */ @@ -102,9 +102,9 @@ // Used in multiple rules /** - * @see AtLeast + * @see FilledAtLeast * @see Nested - * @see OneOf + * @see FilledOnlyOneOf */ '{Property} must be an array or an object. {type} given.' => '{Property} должно быть массивом или объектом. ' . 'Передан {type}.', diff --git a/messages/uz/yii-validator.php b/messages/uz/yii-validator.php index a1f758813..a1363850a 100644 --- a/messages/uz/yii-validator.php +++ b/messages/uz/yii-validator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Compare; use Yiisoft\Validator\Rule\Count; @@ -21,7 +21,7 @@ use Yiisoft\Validator\Rule\Nested; use Yiisoft\Validator\Rule\NotEqual; use Yiisoft\Validator\Rule\Number; -use Yiisoft\Validator\Rule\OneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; use Yiisoft\Validator\Rule\Regex; use Yiisoft\Validator\Rule\Required; use Yiisoft\Validator\Rule\Subset; @@ -31,7 +31,7 @@ return [ // Used in single rule - /** @see AtLeast */ + /** @see FilledAtLeast */ 'At least {min, number} {min, plural, one{property} other{properties}} from this list must be filled' => 'At least {min, number} {min, plural, one{property} other{properties}} from this list must be filled', /** @see BooleanValue */ '{Property} must be either "{true}" or "{false}".' => '{Property} "{true}" yoki "{false}" boʻlishi kerak.', @@ -69,7 +69,7 @@ 'Property "{path}" is not found.' => '{path} xususiyati topilmadi.', /** @see Number */ '{Property} must be a number.' => '{Property} raqam boʻlishi kerak.', - /** @see OneOf */ + /** @see FilledOnlyOneOf */ 'Exactly 1 property from this list must be filled: {properties}.' => 'Exactly 1 property from this list must be filled: {properties}.', /** @see Regex */ '{Property} is invalid.' => '{Property} notoʻgʻri.', @@ -87,9 +87,9 @@ // Used in multiple rules /** - * @see AtLeast + * @see FilledAtLeast * @see Nested - * @see OneOf + * @see FilledOnlyOneOf */ '{Property} must be an array or an object.' => '{Property} massiv yoki obyekt boʻlishi kerak.', /** diff --git a/src/DataSet/ObjectDataSet.php b/src/DataSet/ObjectDataSet.php index 9954f5d1a..c5cfc796b 100644 --- a/src/DataSet/ObjectDataSet.php +++ b/src/DataSet/ObjectDataSet.php @@ -208,7 +208,7 @@ public function __construct( * * ```php * [ - * [new AtLeast(['name', 'author'])], // Rules not bound to a specific property. + * [new FilledAtLeast(['name', 'author'])], // Rules not bound to a specific property. * 'files' => [new Count(max: 3)], // Property specific rules. * ], * ``` diff --git a/src/Helper/ObjectParser.php b/src/Helper/ObjectParser.php index ac03ef33d..c0d43efb8 100644 --- a/src/Helper/ObjectParser.php +++ b/src/Helper/ObjectParser.php @@ -199,7 +199,7 @@ public function __construct( * * ```php * [ - * [new AtLeast(['name', 'author'])], // Parsed from class attribute. + * [new FilledAtLeast(['name', 'author'])], // Parsed from class attribute. * 'files' => [new Count(max: 3)], // Parsed from property attribute. * ], * ``` diff --git a/src/Rule/AtLeast.php b/src/Rule/FilledAtLeast.php similarity index 96% rename from src/Rule/AtLeast.php rename to src/Rule/FilledAtLeast.php index 2d678977d..b6ff9e2a1 100644 --- a/src/Rule/AtLeast.php +++ b/src/Rule/FilledAtLeast.php @@ -22,13 +22,13 @@ * * Both arrays and objects with public properties are supported as validated values. * - * @see AtLeastHandler + * @see FilledAtLeastHandler * * @psalm-import-type SkipOnEmptyValue from SkipOnEmptyInterface * @psalm-import-type WhenType from WhenInterface */ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] -final class AtLeast implements DumpedRuleInterface, SkipOnErrorInterface, WhenInterface, SkipOnEmptyInterface +final class FilledAtLeast implements DumpedRuleInterface, SkipOnErrorInterface, WhenInterface, SkipOnEmptyInterface { use SkipOnEmptyTrait; use SkipOnErrorTrait; @@ -151,6 +151,6 @@ public function getOptions(): array public function getHandler(): string { - return AtLeastHandler::class; + return FilledAtLeastHandler::class; } } diff --git a/src/Rule/AtLeastHandler.php b/src/Rule/FilledAtLeastHandler.php similarity index 90% rename from src/Rule/AtLeastHandler.php rename to src/Rule/FilledAtLeastHandler.php index 53a0535d5..0423e4f96 100644 --- a/src/Rule/AtLeastHandler.php +++ b/src/Rule/FilledAtLeastHandler.php @@ -19,16 +19,16 @@ /** * Validates that a minimum number of specified properties are filled. * - * @see AtLeast + * @see FilledAtLeast */ -final class AtLeastHandler implements RuleHandlerInterface +final class FilledAtLeastHandler implements RuleHandlerInterface { use TranslatedPropertiesHandlerTrait; public function validate(mixed $value, RuleInterface $rule, ValidationContext $context): Result { - if (!$rule instanceof AtLeast) { - throw new UnexpectedRuleException(AtLeast::class, $rule); + if (!$rule instanceof FilledAtLeast) { + throw new UnexpectedRuleException(FilledAtLeast::class, $rule); } /** @var mixed $value */ diff --git a/src/Rule/OneOf.php b/src/Rule/FilledOnlyOneOf.php similarity index 93% rename from src/Rule/OneOf.php rename to src/Rule/FilledOnlyOneOf.php index f95cfb840..56330e00c 100644 --- a/src/Rule/OneOf.php +++ b/src/Rule/FilledOnlyOneOf.php @@ -15,17 +15,17 @@ use Yiisoft\Validator\WhenInterface; /** - * Defines validation options to check that one of specified properties is filled. + * Defines validation options to check that only one of specified properties is filled. * * Both arrays and objects with public properties are supported as validated values. * - * @see OneOfHandler + * @see FilledOnlyOneOfHandler * * @psalm-import-type SkipOnEmptyValue from SkipOnEmptyInterface * @psalm-import-type WhenType from WhenInterface */ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] -final class OneOf implements DumpedRuleInterface, SkipOnErrorInterface, WhenInterface, SkipOnEmptyInterface +final class FilledOnlyOneOf implements DumpedRuleInterface, SkipOnErrorInterface, WhenInterface, SkipOnEmptyInterface { use SkipOnEmptyTrait; use SkipOnErrorTrait; @@ -127,6 +127,6 @@ public function getOptions(): array public function getHandler(): string { - return OneOfHandler::class; + return FilledOnlyOneOfHandler::class; } } diff --git a/src/Rule/OneOfHandler.php b/src/Rule/FilledOnlyOneOfHandler.php similarity index 84% rename from src/Rule/OneOfHandler.php rename to src/Rule/FilledOnlyOneOfHandler.php index 44cd81567..42c336ed6 100644 --- a/src/Rule/OneOfHandler.php +++ b/src/Rule/FilledOnlyOneOfHandler.php @@ -17,18 +17,18 @@ use function is_object; /** - * Validates that one of specified properties is filled. + * Validates that only one of specified properties is filled. * - * @see OneOf + * @see FilledOnlyOneOf */ -final class OneOfHandler implements RuleHandlerInterface +final class FilledOnlyOneOfHandler implements RuleHandlerInterface { use TranslatedPropertiesHandlerTrait; public function validate(mixed $value, RuleInterface $rule, ValidationContext $context): Result { - if (!$rule instanceof OneOf) { - throw new UnexpectedRuleException(OneOf::class, $rule); + if (!$rule instanceof FilledOnlyOneOf) { + throw new UnexpectedRuleException(FilledOnlyOneOf::class, $rule); } /** @var mixed $value */ @@ -58,7 +58,7 @@ public function validate(mixed $value, RuleInterface $rule, ValidationContext $c return $filledCount === 1 ? $result : $this->getGenericErrorResult($rule, $context); } - private function getGenericErrorResult(OneOf $rule, ValidationContext $context): Result + private function getGenericErrorResult(FilledOnlyOneOf $rule, ValidationContext $context): Result { return (new Result())->addError($rule->getMessage(), [ 'property' => $context->getTranslatedProperty(), diff --git a/src/RuleHandlerResolver/SimpleRuleHandlerContainer.php b/src/RuleHandlerResolver/SimpleRuleHandlerContainer.php index 4af1dc59d..21c3bcb9c 100644 --- a/src/RuleHandlerResolver/SimpleRuleHandlerContainer.php +++ b/src/RuleHandlerResolver/SimpleRuleHandlerContainer.php @@ -30,7 +30,7 @@ * It's also possible to replace a handler for built-in rule with a custom one: * * ```php - * $container = new SimpleRuleHandlerContainer([AtLeast::class => new MyAtLeastHandler()]); + * $container = new SimpleRuleHandlerContainer([FilledAtLeast::class => new MyFilledAtLeastHandler()]); * $validator = new Validator(ruleHandlerResolver: $container); * ``` */ diff --git a/src/RuleInterface.php b/src/RuleInterface.php index cd39cdc17..03728aa07 100644 --- a/src/RuleInterface.php +++ b/src/RuleInterface.php @@ -15,7 +15,7 @@ interface RuleInterface * A matching handler name or an instance used for processing this rule. * * While not required, for naming of handlers' classes it's recommended to use a rule class name with "Handler" - * suffix, so for `AtLeast` rule class name the handler class name will be `AtLeastHandler` and so on. + * suffix, so for `FilledAtLeast` rule class name the handler class name will be `FilledAtLeastHandler` and so on. * * All packages handlers are stored within the same namespace as rules, but this is not a strict requirement. * diff --git a/src/RulesProvider/AttributesRulesProvider.php b/src/RulesProvider/AttributesRulesProvider.php index dfd4c2bec..2fd886005 100644 --- a/src/RulesProvider/AttributesRulesProvider.php +++ b/src/RulesProvider/AttributesRulesProvider.php @@ -126,7 +126,7 @@ public function __construct( * * ```php * [ - * [new AtLeast(['name', 'author'])], // Rules not bound to a specific property. + * [new FilledAtLeast(['name', 'author'])], // Rules not bound to a specific property. * 'files' => [new Count(max: 3)], // Property specific rules. * ], * ``` diff --git a/tests/Rule/AtLeastTest.php b/tests/Rule/FilledAtLeastTest.php similarity index 78% rename from tests/Rule/AtLeastTest.php rename to tests/Rule/FilledAtLeastTest.php index 822e01575..720b66ce7 100644 --- a/tests/Rule/AtLeastTest.php +++ b/tests/Rule/FilledAtLeastTest.php @@ -6,8 +6,8 @@ use InvalidArgumentException; use Yiisoft\Validator\EmptyCondition\NeverEmpty; -use Yiisoft\Validator\Rule\AtLeast; -use Yiisoft\Validator\Rule\AtLeastHandler; +use Yiisoft\Validator\Rule\FilledAtLeast; +use Yiisoft\Validator\Rule\FilledAtLeastHandler; use Yiisoft\Validator\Tests\Rule\Base\DifferentRuleInHandlerTestTrait; use Yiisoft\Validator\Tests\Rule\Base\RuleTestCase; use Yiisoft\Validator\Tests\Rule\Base\RuleWithOptionsTestTrait; @@ -16,7 +16,7 @@ use Yiisoft\Validator\Tests\Support\Data\AtLeastDto; use Yiisoft\Validator\ValidationContext; -final class AtLeastTest extends RuleTestCase +final class FilledAtLeastTest extends RuleTestCase { use DifferentRuleInHandlerTestTrait; use RuleWithOptionsTestTrait; @@ -27,26 +27,26 @@ public function testMinGreaterThanPropertiesCount(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('$min must be no greater than amount of $properties.'); - new AtLeast(['prop'], min: 2); + new FilledAtLeast(['prop'], min: 2); } public function testGetName(): void { - $rule = new AtLeast(['prop']); - $this->assertSame(AtLeast::class, $rule->getName()); + $rule = new FilledAtLeast(['prop']); + $this->assertSame(FilledAtLeast::class, $rule->getName()); } public function testPropertyIsNull(): void { $data = ['prop1' => 1, 'prop2' => null]; - $rule = new AtLeast( + $rule = new FilledAtLeast( properties: ['prop1', 'prop2'], min: 2, message: 'properties - {properties}, property - {property}, min - {min}.', ); $context = new ValidationContext(); - (new AtLeastHandler())->validate($data, $rule, $context); + (new FilledAtLeastHandler())->validate($data, $rule, $context); $this->assertNull($context->getPropertyLabel()); } @@ -55,7 +55,7 @@ public function dataOptions(): array { return [ 'default' => [ - new AtLeast(['prop1', 'prop2']), + new FilledAtLeast(['prop1', 'prop2']), [ 'properties' => [ 'prop1', @@ -76,7 +76,7 @@ public function dataOptions(): array ], ], 'custom' => [ - new AtLeast( + new FilledAtLeast( ['prop1', 'prop2'], min: 2, incorrectInputMessage: 'Custom message 1.', @@ -103,7 +103,7 @@ public function dataOptions(): array ], ], 'callable skip on empty' => [ - new AtLeast(['prop1', 'prop2'], skipOnEmpty: new NeverEmpty()), + new FilledAtLeast(['prop1', 'prop2'], skipOnEmpty: new NeverEmpty()), [ 'properties' => [ 'prop1', @@ -134,29 +134,29 @@ public function dataValidationPassed(): array public $prop1 = 1; public $prop2 = null; }, - [new AtLeast(['prop1', 'prop2'])], + [new FilledAtLeast(['prop1', 'prop2'])], ], [ new class () { public $prop1 = null; public $prop2 = 1; }, - [new AtLeast(['prop2'])], + [new FilledAtLeast(['prop2'])], ], [ new class () { private int $prop1 = 1; private $prop2 = null; }, - [new AtLeast(['prop1', 'prop2'])], + [new FilledAtLeast(['prop1', 'prop2'])], ], [ ['prop1' => 1, 'prop2' => null], - [new AtLeast(['prop1', 'prop2'])], + [new FilledAtLeast(['prop1', 'prop2'])], ], [ ['prop1' => null, 'prop2' => 1], - [new AtLeast(['prop2'])], + [new FilledAtLeast(['prop2'])], ], [ new class () { @@ -170,7 +170,7 @@ public function __construct() }; } }, - ['obj' => new AtLeast(['prop1', 'prop2'])], + ['obj' => new FilledAtLeast(['prop1', 'prop2'])], ], [ new class () { @@ -184,27 +184,27 @@ public function __construct() }; } }, - ['obj' => new AtLeast(['prop2'])], + ['obj' => new FilledAtLeast(['prop2'])], ], [ ['obj' => ['prop1' => 1, 'prop2' => null]], - ['obj' => new AtLeast(['prop1', 'prop2'])], + ['obj' => new FilledAtLeast(['prop1', 'prop2'])], ], [ ['obj' => ['prop1' => null, 'prop2' => 1]], - ['obj' => new AtLeast(['prop2'])], + ['obj' => new FilledAtLeast(['prop2'])], ], 'more than "min" properties are filled' => [ ['prop1' => 1, 'prop2' => 2], - [new AtLeast(['prop1', 'prop2'])], + [new FilledAtLeast(['prop1', 'prop2'])], ], 'min equals amount of properties' => [ ['prop1' => 1, 'prop2' => 2], - [new AtLeast(['prop1', 'prop2'], min: 2)], + [new FilledAtLeast(['prop1', 'prop2'], min: 2)], ], 'min equals amount of properties, 0' => [ [], - [new AtLeast([], min: 0)], + [new FilledAtLeast([], min: 0)], ], 'class property' => [ new AtLeastDto(1), @@ -223,23 +223,23 @@ public function dataValidationFailed(): array return [ 'incorrect input' => [ 1, - [new AtLeast(['prop2'])], + [new FilledAtLeast(['prop2'])], ['' => ['Value must be an array or an object. int given.']], ], 'custom incorrect input message' => [ 1, - [new AtLeast(['prop2'], incorrectInputMessage: 'Custom incorrect input message.')], + [new FilledAtLeast(['prop2'], incorrectInputMessage: 'Custom incorrect input message.')], ['' => ['Custom incorrect input message.']], ], 'custom incorrect input message with parameters' => [ 1, - [new AtLeast(['prop2'], incorrectInputMessage: 'Property - {Property}, type - {type}.')], + [new FilledAtLeast(['prop2'], incorrectInputMessage: 'Property - {Property}, type - {type}.')], ['' => ['Property - Value, type - int.']], ], 'custom incorrect input message with parameters, property set' => [ ['property' => 1], [ - 'property' => new AtLeast( + 'property' => new FilledAtLeast( ['prop2'], incorrectInputMessage: 'Property - {property}, type - {type}.', ), @@ -248,37 +248,37 @@ public function dataValidationFailed(): array ], 'object' => [ $class, - [new AtLeast(['prop2'])], + [new FilledAtLeast(['prop2'])], ['' => ['At least 1 property from this list must be filled for value: "prop2".']], ], 'object, custom min' => [ $class, - [new AtLeast(['prop1', 'prop2'], min: 2)], + [new FilledAtLeast(['prop1', 'prop2'], min: 2)], ['' => ['At least 2 properties from this list must be filled for value: "prop1", "prop2".']], ], 'array' => [ $array, - [new AtLeast(['prop2'])], + [new FilledAtLeast(['prop2'])], ['' => ['At least 1 property from this list must be filled for value: "prop2".']], ], 'array, custom min' => [ $array, - [new AtLeast(['prop1', 'prop2'], min: 2)], + [new FilledAtLeast(['prop1', 'prop2'], min: 2)], ['' => ['At least 2 properties from this list must be filled for value: "prop1", "prop2".']], ], 'custom message' => [ $class, - [new AtLeast(['prop1', 'prop2'], min: 2, message: 'Custom message.')], + [new FilledAtLeast(['prop1', 'prop2'], min: 2, message: 'Custom message.')], ['' => ['Custom message.']], ], 'custom message with parameters' => [ $class, - [new AtLeast(['prop1', 'prop2'], min: 2, message: 'Properties - {Properties}, min - {min}.')], + [new FilledAtLeast(['prop1', 'prop2'], min: 2, message: 'Properties - {Properties}, min - {min}.')], ['' => ['Properties - "Prop1", "Prop2", min - 2.']], ], 'custom message with parameters, property set' => [ ['data' => $class], - ['data' => new AtLeast(['prop1', 'prop2'], min: 2, message: 'Properties - {properties}, min - {min}.')], + ['data' => new FilledAtLeast(['prop1', 'prop2'], min: 2, message: 'Properties - {properties}, min - {min}.')], ['data' => ['Properties - "prop1", "prop2", min - 2.']], ], 'class property, translated properties' => [ @@ -291,17 +291,17 @@ public function dataValidationFailed(): array public function testSkipOnError(): void { - $this->testSkipOnErrorInternal(new AtLeast(['prop']), new AtLeast(['prop'], skipOnError: true)); + $this->testSkipOnErrorInternal(new FilledAtLeast(['prop']), new FilledAtLeast(['prop'], skipOnError: true)); } public function testWhen(): void { $when = static fn (mixed $value): bool => $value !== null; - $this->testWhenInternal(new AtLeast(['prop']), new AtLeast(['prop'], when: $when)); + $this->testWhenInternal(new FilledAtLeast(['prop']), new FilledAtLeast(['prop'], when: $when)); } protected function getDifferentRuleInHandlerItems(): array { - return [AtLeast::class, AtLeastHandler::class]; + return [FilledAtLeast::class, FilledAtLeastHandler::class]; } } diff --git a/tests/Rule/OneOfTest.php b/tests/Rule/FilledOnlyOneOfTest.php similarity index 76% rename from tests/Rule/OneOfTest.php rename to tests/Rule/FilledOnlyOneOfTest.php index 189b851f2..d851a9a02 100644 --- a/tests/Rule/OneOfTest.php +++ b/tests/Rule/FilledOnlyOneOfTest.php @@ -5,16 +5,16 @@ namespace Yiisoft\Validator\Tests\Rule; use Yiisoft\Validator\EmptyCondition\NeverEmpty; -use Yiisoft\Validator\Rule\OneOf; -use Yiisoft\Validator\Rule\OneOfHandler; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOfHandler; use Yiisoft\Validator\Tests\Rule\Base\DifferentRuleInHandlerTestTrait; use Yiisoft\Validator\Tests\Rule\Base\RuleTestCase; use Yiisoft\Validator\Tests\Rule\Base\RuleWithOptionsTestTrait; use Yiisoft\Validator\Tests\Rule\Base\SkipOnErrorTestTrait; use Yiisoft\Validator\Tests\Rule\Base\WhenTestTrait; -use Yiisoft\Validator\Tests\Support\Data\OneOfDto; +use Yiisoft\Validator\Tests\Support\Data\FilledOnlyOneOfDto; -final class OneOfTest extends RuleTestCase +final class FilledOnlyOneOfTest extends RuleTestCase { use DifferentRuleInHandlerTestTrait; use RuleWithOptionsTestTrait; @@ -23,15 +23,15 @@ final class OneOfTest extends RuleTestCase public function testGetName(): void { - $rule = new OneOf([]); - $this->assertSame(OneOf::class, $rule->getName()); + $rule = new FilledOnlyOneOf([]); + $this->assertSame(FilledOnlyOneOf::class, $rule->getName()); } public function dataOptions(): array { return [ 'default' => [ - new OneOf(['prop1', 'prop2']), + new FilledOnlyOneOf(['prop1', 'prop2']), [ 'properties' => [ 'prop1', @@ -50,7 +50,7 @@ public function dataOptions(): array ], ], 'custom' => [ - new OneOf( + new FilledOnlyOneOf( ['prop1', 'prop2'], incorrectInputMessage: 'Custom message 1.', message: 'Custom message 2.', @@ -75,7 +75,7 @@ public function dataOptions(): array ], ], 'callable skip on empty' => [ - new OneOf(['prop1', 'prop2'], skipOnEmpty: new NeverEmpty()), + new FilledOnlyOneOf(['prop1', 'prop2'], skipOnEmpty: new NeverEmpty()), [ 'properties' => [ 'prop1', @@ -104,29 +104,29 @@ public function dataValidationPassed(): array public $prop1 = 1; public $prop2 = null; }, - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ new class () { public $prop1 = null; public $prop2 = 1; }, - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ new class () { private int $prop1 = 1; private $prop2 = null; }, - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ ['prop1' => 1, 'prop2' => null], - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ ['prop1' => null, 'prop2' => 1], - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ new class () { @@ -140,7 +140,7 @@ public function __construct() }; } }, - ['obj' => new OneOf(['prop1', 'prop2'])], + ['obj' => new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ new class () { @@ -154,18 +154,18 @@ public function __construct() }; } }, - ['obj' => new OneOf(['prop1', 'prop2'])], + ['obj' => new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ ['obj' => ['prop1' => 1, 'prop2' => null]], - ['obj' => new OneOf(['prop1', 'prop2'])], + ['obj' => new FilledOnlyOneOf(['prop1', 'prop2'])], ], [ ['obj' => ['prop1' => null, 'prop2' => 1]], - ['obj' => new OneOf(['prop1', 'prop2'])], + ['obj' => new FilledOnlyOneOf(['prop1', 'prop2'])], ], 'class property, translation' => [ - new OneOfDto(1), + new FilledOnlyOneOfDto(1), ], ]; } @@ -181,23 +181,23 @@ public function dataValidationFailed(): array return [ 'incorrect input' => [ 1, - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ['' => ['Value must be an array or an object. int given.']], ], 'custom incorrect input message' => [ 1, - [new OneOf(['prop1', 'prop2'], incorrectInputMessage: 'Custom incorrect input message.')], + [new FilledOnlyOneOf(['prop1', 'prop2'], incorrectInputMessage: 'Custom incorrect input message.')], ['' => ['Custom incorrect input message.']], ], 'custom incorrect input message with parameters' => [ 1, - [new OneOf(['prop1', 'prop2'], incorrectInputMessage: 'Property - {property}, type - {type}.')], + [new FilledOnlyOneOf(['prop1', 'prop2'], incorrectInputMessage: 'Property - {property}, type - {type}.')], ['' => ['Property - value, type - int.']], ], 'custom incorrect input message with parameters, property set' => [ ['property' => 1], [ - 'property' => new OneOf( + 'property' => new FilledOnlyOneOf( ['prop1', 'prop2'], incorrectInputMessage: 'Property - {property}, type - {type}.', ), @@ -206,36 +206,36 @@ public function dataValidationFailed(): array ], 'object' => [ $object, - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ['' => ['Exactly 1 property from this list must be filled for value: "prop1", "prop2".']], ], 'array' => [ $array, - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ['' => ['Exactly 1 property from this list must be filled for value: "prop1", "prop2".']], ], 'more than 1 property is filled' => [ ['prop1' => 1, 'prop2' => 2], - [new OneOf(['prop1', 'prop2'])], + [new FilledOnlyOneOf(['prop1', 'prop2'])], ['' => ['Exactly 1 property from this list must be filled for value: "prop1", "prop2".']], ], 'custom message' => [ $object, - [new OneOf(['prop1', 'prop2'], message: 'Custom message.')], + [new FilledOnlyOneOf(['prop1', 'prop2'], message: 'Custom message.')], ['' => ['Custom message.']], ], 'custom message with parameters' => [ $object, - [new OneOf(['prop1', 'prop2'], message: 'Properties - {Properties}.')], + [new FilledOnlyOneOf(['prop1', 'prop2'], message: 'Properties - {Properties}.')], ['' => ['Properties - "Prop1", "Prop2".']], ], 'custom message with parameters, property set' => [ ['data' => $object], - ['data' => new OneOf(['prop1', 'prop2'], message: 'Properties - {properties}.')], + ['data' => new FilledOnlyOneOf(['prop1', 'prop2'], message: 'Properties - {properties}.')], ['data' => ['Properties - "prop1", "prop2".']], ], 'class property' => [ - new OneOfDto(), + new FilledOnlyOneOfDto(), null, ['' => ['Exactly 1 property from this list must be filled for value: "A", "B", "C".']], ], @@ -244,17 +244,17 @@ public function dataValidationFailed(): array public function testSkipOnError(): void { - $this->testSkipOnErrorInternal(new OneOf([]), new OneOf([], skipOnError: true)); + $this->testSkipOnErrorInternal(new FilledOnlyOneOf([]), new FilledOnlyOneOf([], skipOnError: true)); } public function testWhen(): void { $when = static fn (mixed $value): bool => $value !== null; - $this->testWhenInternal(new OneOf([]), new OneOf([], when: $when)); + $this->testWhenInternal(new FilledOnlyOneOf([]), new FilledOnlyOneOf([], when: $when)); } protected function getDifferentRuleInHandlerItems(): array { - return [OneOf::class, OneOfHandler::class]; + return [FilledOnlyOneOf::class, FilledOnlyOneOfHandler::class]; } } diff --git a/tests/Rule/NestedTest.php b/tests/Rule/NestedTest.php index b5a1264f8..2bf5b2f93 100644 --- a/tests/Rule/NestedTest.php +++ b/tests/Rule/NestedTest.php @@ -13,7 +13,7 @@ use Yiisoft\Validator\Error; use Yiisoft\Validator\Helper\RulesDumper; use Yiisoft\Validator\Result; -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Callback; use Yiisoft\Validator\Rule\Count; @@ -515,7 +515,7 @@ public function dataPropagateOptions(): array ], 'single rule as integer property rules' => [ new Nested( - [new AtLeast(['a'])], + [new FilledAtLeast(['a'])], propagateOptions: true, skipOnEmpty: true, skipOnError: true, @@ -527,7 +527,7 @@ public function dataPropagateOptions(): array 'skipOnError' => true, 'rules' => [ [ - AtLeast::class, + FilledAtLeast::class, 'skipOnEmpty' => true, 'skipOnError' => true, ], diff --git a/tests/Support/Data/AtLeastDto.php b/tests/Support/Data/AtLeastDto.php index f1fb328f7..c6a46793e 100644 --- a/tests/Support/Data/AtLeastDto.php +++ b/tests/Support/Data/AtLeastDto.php @@ -7,9 +7,9 @@ use Yiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator; use Yiisoft\Validator\PropertyTranslatorInterface; use Yiisoft\Validator\PropertyTranslatorProviderInterface; -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; -#[AtLeast(['a', 'b', 'c'])] +#[FilledAtLeast(['a', 'b', 'c'])] final class AtLeastDto implements PropertyTranslatorProviderInterface { public function __construct( diff --git a/tests/Support/Data/OneOfDto.php b/tests/Support/Data/FilledOnlyOneOfDto.php similarity index 82% rename from tests/Support/Data/OneOfDto.php rename to tests/Support/Data/FilledOnlyOneOfDto.php index 9e12c4cc1..36c00f09e 100644 --- a/tests/Support/Data/OneOfDto.php +++ b/tests/Support/Data/FilledOnlyOneOfDto.php @@ -7,10 +7,10 @@ use Yiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator; use Yiisoft\Validator\PropertyTranslatorInterface; use Yiisoft\Validator\PropertyTranslatorProviderInterface; -use Yiisoft\Validator\Rule\OneOf; +use Yiisoft\Validator\Rule\FilledOnlyOneOf; -#[OneOf(['a', 'b', 'c'])] -final class OneOfDto implements PropertyTranslatorProviderInterface +#[FilledOnlyOneOf(['a', 'b', 'c'])] +final class FilledOnlyOneOfDto implements PropertyTranslatorProviderInterface { public function __construct( public ?int $a = null, diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 49e76ec82..d7693a309 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -19,7 +19,7 @@ use Yiisoft\Validator\Exception\RuleHandlerNotFoundException; use Yiisoft\Validator\Label; use Yiisoft\Validator\Result; -use Yiisoft\Validator\Rule\AtLeast; +use Yiisoft\Validator\Rule\FilledAtLeast; use Yiisoft\Validator\Rule\BooleanValue; use Yiisoft\Validator\Rule\Compare; use Yiisoft\Validator\Rule\In; @@ -1484,8 +1484,8 @@ public function testDifferentValueAsArrayInSameContext(): void $result = (new Validator())->validate( ['x' => ['a' => 1, 'b' => 2]], [ - new AtLeast(['x']), - 'x' => new AtLeast(['a', 'b']), + new FilledAtLeast(['x']), + 'x' => new FilledAtLeast(['a', 'b']), ], ); $this->assertTrue($result->isValid());