Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 1.x to master #685

Merged
merged 13 commits into from
Apr 5, 2024
Merged

Merge 1.x to master #685

merged 13 commits into from
Apr 5, 2024

Conversation

vjik
Copy link
Member

@vjik vjik commented Apr 4, 2024

Q A
Is bugfix?
New feature?
Breaks BC?
Fixed issues

Arhell and others added 12 commits February 23, 2024 09:14
Co-authored-by: Alexey Rogachev <arogachev90@gmail.com>
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
* Add aspect ratio support to `Image` rule

* Apply fixes from StyleCI

* Code coverage, mutants

* Add detailed test cases' descriptions in data providers

* Change placeholders

* Work with options

* Work with options 2

* More configuration checks

* Fix logic, add PHPDoc

* Use value object for aspect ratio

* Actualize fix for mutant for absolute margin

* Fix error messages

* Fix new mutants

* Update src/Rule/Image/ImageAspectRatio.php

Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>

* Do not use dedicated container in tests, fix last mutant

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>
# Conflicts:
#	composer-require-checker.json
#	docs/guide/en/result.md
#	messages/ru/yii-validator.php
#	src/Result.php
#	tests/ValidatorTest.php
@vjik vjik changed the base branch from 1.x to master April 4, 2024 12:07
Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 93.07832% with 38 lines in your changes are missing coverage. Please review.

Project coverage is 94.40%. Comparing base (741d99a) to head (4b33fd5).
Report is 3 commits behind head on master.

Files Patch % Lines
src/Rule/Date/DateTime.php 40.00% 15 Missing ⚠️
src/Rule/Date/Time.php 28.57% 15 Missing ⚠️
src/Rule/Date/DateTimeHandler.php 76.47% 4 Missing ⚠️
src/Rule/Date/DateHandler.php 86.66% 2 Missing ⚠️
src/Rule/Date/TimeHandler.php 86.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #685      +/-   ##
============================================
- Coverage     94.72%   94.40%   -0.33%     
- Complexity      801      953     +152     
============================================
  Files            93      108      +15     
  Lines          2483     3018     +535     
============================================
+ Hits           2352     2849     +497     
- Misses          131      169      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

what-the-diff bot commented Apr 4, 2024

  • In .github/workflows/bc.yml, the php version was changed from 8.0 to 8.1.
  • In .github/workflows/bench.yml, the php version was changed from 8.0, 8.1 to just 8.1.
  • In .github/workflows/build.yml, the php version was changed from 8.0, 8.1, 8.2, 8.3 to 8.1, 8.2, 8.3.
  • In .github/workflows/composer-require-checker.yml, the php version was changed from 8.0, 8.1, 8.2, 8.3 to 8.1, 8.2, 8.3.
  • In .github/workflows/static.yml, the php version was changed from 8.0 to 8.1, 8.2, 8.3.
  • In CHANGELOG.md, several changes were documented, including adding new features, enhancing existing features, and fixing bugs.
  • In composer-require-checker.json, the JetBrains\PhpStorm\Language and json_validate dependencies were added.
  • In composer.json, the minimum required php version was changed from 8.0 to 8.1, and the vimeo/psalm dependency version was changed from ^4.30|^5.22 to ^5.22.
  • In docs/guide/en/client-side-validation.md, the label for the length rule was changed to Yiisoft\Validator\Rule\Length.
  • In docs/guide/en/configuring-rules-via-php-attributes.md, a new example was added to show how to specify a custom label for a property.
  • In docs/guide/en/creating-custom-rules.md, the getName() method was removed from the RgbColor class.
  • In docs/guide/en/customizing-error-messages.md, there were changes in the examples of custom error messages.
  • In docs/guide/en/using-validator.md, the PersonRulesProvider class was changed to a regular class instead of implementing RulesProviderInterface.
  • In docs/guide/ru/README.md, a new Russian translation of the guide was added.
  • In docs/guide/ru/conditional-validation.md, a new guide was added about conditional validation.
  • In docs/guide/ru/README.md, several new sections were added to the guide.
  • In docs/guide/ru/customizing-error-messages.md, the translation of the error message was changed.
  • In docs/guide/ru/using-validator.md, a new example was added to show how to use a custom "empty condition" callback.
  • A new file docs/guide/ru/conditional-validation.md was added to the guide.
  • In docs/guide/ru/conditional-validation.md, the new guide was added about conditional validation.
  • In docs/guide/ru/customizing-error-messages.md, the translation of the error message was changed.
  • In docs/guide/ru/using-validator.md, a new example was added to show how to use a custom "empty condition" callback.
  • Several other minor changes were made in the files docs/guide/ru/, composer-require-checker.json, and composer.json.
  • A new file docs/guide/ru/conditional-validation.md was added to the guide.
  • In docs/guide/ru/conditional-validation.md, the new guide was added about conditional validation.
  • In docs/guide/ru/customizing-error-messages.md, the translation of the error message was changed.
  • In docs/guide/ru/using-validator.md, a new example was added to show how to use a custom "empty condition" callback.
  • Several other minor changes were made in the files docs/guide/ru/, composer-require-checker.json, and composer.json.
* Added a new file `customizing-error-messages.md` in the `docs/guide/ru/` directory, which contains information about customizing error messages in the framework.
* Added a new file `result.md` in the `docs/guide/ru/` directory, which contains information about the result of validation, including checking the validation status, retrieving error messages, and filtering errors.
* Added a new file `using-validator.md` in the `docs/guide/ru/` directory, which contains information about using the validator to validate data in different formats.
* Updated the `infection.json.dist` file to ignore specific lines of code during mutation testing.
* Ignored specific lines of code in the `NullAttributeTranslator` class to exclude them from mutation testing.
  • In the file yii-validator.php under messages/de/, the following changes were made:
  • Added multiple new validator rules such as AtLeast, BooleanValue, Count, Each, Email, In, Ip, Integer, Json, Length, Nested, Number, OneOf, Regex, Required, Subset, TrueValue, and Url.
  • In the file yii-validator.php under messages/pl/, the following changes were made:
  • Updated translations for existing validator rules.
  • Added multiple new validator rules such as AtLeast, BooleanValue, Count, Each, Email, In, Ip, Integer, Json, Length, Nested, Number, OneOf, Regex, Required, Subset, TrueValue, and Url.
* The changes in the `messages/ru/yii-validator.php` file include:
- The translation of the message `'The data must have at least "{min}" filled attributes.'` was changed to `'At least {min, number} {min, plural, one{attribute} other{attributes}} from this list must be filled'`
- The translation of the message `'Value must be either "{true}" or "{false}".'` was changed to `'"{Attribute}" must be either "{true}" or "{false}".'`
- The translation of the message `'This value must be an array or implement \Countable interface.'` was changed to `'"{Attribute}" must be an array or implement \Countable interface.'`
- The translation of the message `'This value must contain at least {min, number} {min, plural, one{item} other{items}}.'` was changed to `'"{Attribute}" must contain at least {min, number} {min, plural, one{item} other{items}}.'`
- The translation of the message `'This value must contain at most {max, number} {max, plural, one{item} other{items}}.'` was changed to `'"{Attribute}" must contain at most {max, number} {max, plural, one{item} other{items}}.'`
- The translation of the message `'This value must contain exactly {exactly, number} {exactly, plural, one{item} other{items}}.'` was changed to `'"{Attribute}" must contain exactly {exactly, number} {exactly, plural, one{item} other{items}}.'`
- The translation of the message `'Value must be array or iterable.'` was changed to `'"{Attribute}" must be array or iterable.'`
- The translation of the message `'This value is not a valid email address.'` was changed to `'"{Attribute}" is not a valid email address.'`
- The translation of the message `'This value is not in the list of acceptable values.'` was changed to `'"{Attribute}" is not in the list of acceptable values.'`
- The translation of the message `'Must be a valid IP address.'` was changed to `'"{Attribute}" must be a valid IP address.'`
- The translation of the message `'Must not be an IPv4 address.'` was changed to `'"{Attribute}" must not be an IPv4 address.'`
- The translation of the message `'Must not be an IPv6 address.'` was changed to `'"{Attribute}" must not be an IPv6 address.'`
- The translation of the message `'Contains wrong subnet mask.'` was changed to `'"{Attribute}" contains wrong subnet mask.'`
- The translation of the message `'Must be an IP address with specified subnet.'` was changed to `'"{Attribute}" must be an IP address with specified subnet.'`
- The translation of the message `'Must not be a subnet.'` was changed to `'"{Attribute}" must not be a subnet.'`
- The translation of the message `'Is not in the allowed range.'` was changed to `'"{Attribute}" is not in the allowed range.'`
- The translation of the message `'Value must be an integer.'` was changed to `'"{Attribute}" must be an integer.'`
- The translation of the message `'The value is not JSON.'` was changed to `'"{Attribute}" is not JSON.'`
- The translation of the message `'This value must contain at least {min, number} {min, plural, one{character} other{characters}}.'` was changed to `'"{Attribute}" must contain at least {min, number} {min, plural, one{character} other{characters}}.'`
- The translation of the message `'This value must contain at most {max, number} {max, plural, one{character} other{characters}}.'` was changed to `'"{Attribute}" must contain at most {max, number} {max, plural, one{character} other{characters}}.'`
- The translation of the message `'This value must contain exactly {exactly, number} {exactly, plural, one{character} other{characters}}.'` was changed to `'"{Attribute}" must contain exactly {exactly, number} {exactly, plural, one{character} other{characters}}.'`
- The translation of the message `'The value must be an array or an object.'` was changed to `'"{Attribute}" must be an array or an object.'`
- The translation of the message `'The value must be "{true}".'` was changed to `'"{Attribute}" must be "{true}".'`
- The translation of the message `'This value is not a valid URL.'` was changed to `'"{Attribute}" is not a valid URL.'`
* The file `messages/uz/yii-validator.php` has the same changes as `messages/ru/yii-validator.php`
* The file `psalm80.xml` was deleted.
* Added `LabelsProviderInterface` which provides data attribute labels.
* Renamed `RuleWithOptionsInterface` to `DumpedRuleInterface`.
* Added `Label` class to parse labels specified via `Label` attributes.
* Updated `ObjectDataSet` to implement `LabelsProviderInterface` and added `getValidationPropertyLabels` method.
* Updated `ObjectParser` to parse labels specified via `Label` attributes.
* Updated `RulesDumper` to handle `DumpedRuleInterface` and dump rule options and name.
* Updated various rule classes to implement `DumpedRuleInterface` and define rule name.
* Updated rule handlers to use translated attributes and improved error messages.
* Added `LabelsProviderInterface` to provide a set of attribute labels.
* Updated `Result` class to improve error messages.

Note: The diff includes multiple changes to different files, so the summary includes all the changes.

  • The Count class in the file src/Rule/Count.php now implements the DumpedRuleInterface interface.
  • The CountHandler.php file was added.
  • The DateTime class was added to the file src/Rule/DateTime.php.
  • The DateTimeHandler.php file was added.
  • The Each class in the file src/Rule/Each.php now implements the DumpedRuleInterface interface.
  • The EachHandler.php file was added.
  • The Email class in the file src/Rule/Email.php now implements the DumpedRuleInterface interface.
  • The EmailHandler.php file was added.
  • The Equal class in the file src/Rule/Equal.php no longer implements the getName method.
  • The GreaterThan class in the file src/Rule/GreaterThan.php no longer implements the getName method.
  • The GreaterThanOrEqual class in the file src/Rule/GreaterThanOrEqual.php no longer implements the getName method.
  • The Image class in the file src/Rule/Image/Image.php now implements the DumpedRuleInterface interface.
  • The In class in the file src/Rule/In.php now implements the DumpedRuleInterface interface.
  • The InHandler.php file was added.
  • The Integer class in the file src/Rule/Integer.php no longer implements the getName method.
  • The Ip class in the file src/Rule/Ip.php now implements the DumpedRuleInterface interface.
  • The IpHandler.php file was added.
  • The validate method in the EmailHandler.php now has an additional parameter $context which is used to capitalize the Attribute placeholder in error messages.
  • The validate method in the IpHandler.php now has an additional parameter $context which is used to capitalize the Attribute placeholder in error messages.
Notes:
- The changes in files `Count.php`, `Each.php`, `Email.php`, and `Ip.php` are related to implementing the `DumpedRuleInterface` interface. The interface is used to mark rule classes that can be serialized/deserialized.
* Added `DumpedRuleInterface` to the following classes: 
- `Rule\Json`
- `Rule\Length`
- `Rule\Nested`
- `Rule\OneOf`
- `Rule\Regex`
- `Rule\Required`
* In `Rule\Json`:
- Updated the default values for the `$incorrectInputMessage` and `$message` properties.
- Updated the `getName()` method to return `self::class` instead of `'json'`.
* In `Rule\JsonHandler`:
- Added a new `use` statement for the `function_exists()` function.
- Modified the `isValidJson()` method to use the `json_validate()` function if it exists.
- Updated the error messages to include attribute placeholders.
* In `Rule\Length`:
- Updated the default values for the `$incorrectInputMessage`, `$lessThanMinMessage`, `$greaterThanMaxMessage`, and `$notExactlyMessage` properties.
- Updated the `getName()` method to return `self::class` instead of `'length'`.
* In `Rule\LengthHandler`:
- Updated the error messages to include attribute placeholders.
* In `Rule\Nested`:
- Added `DumpedRuleInterface` to the class.
- Updated the default values for the `$incorrectInputMessage`, `$noPropertyPathMessage`, and `$noRulesWithNoObjectMessage` properties.
- Updated the `getName()` method to return `self::class` instead of `'nested'`.
* In `Rule\NestedHandler`:
- Updated the error messages to include attribute placeholders.
* In `Rule\Number`:
- Updated the default values for the `$incorrectInputMessage`, `$notNumberMessage`, `$lessThanMinMessage`, and `$greaterThanMaxMessage` properties.
- Updated the `getName()` method to return `self::class` instead of `'number'`.
* In `Rule\NumberHandler`:
- Updated the error messages to include attribute placeholders.
* In `Rule\OneOf`:
- Added `DumpedRuleInterface` to the class.
- Updated the default values for the `$incorrectInputMessage` and `$message` properties.
- Updated the `getName()` method to return `self::class` instead of `'oneOf'`.
* In `Rule\OneOfHandler`:
- Updated the error messages to include attribute placeholders.
* In `Rule\Regex`:
- Added `DumpedRuleInterface` to the class.
- Updated the default values for the `$incorrectInputMessage` and `$message` properties.
- Updated the `getName()` method to return `self::class` instead of `'regex'`.
* In `Rule\RegexHandler`:
- Updated the error messages to include attribute placeholders.
* In `Rule\Required`:
- Added `DumpedRuleInterface` to the class.
- Updated the default values for the `$message` and `$notPassedMessage` properties.
- Updated the `getName()` method to return `self::class` instead of `'required'`.
- Updated the `getRequiredCondition()` method to return `$emptyCondition` if it is callable, otherwise it returns an internal function.
  • The RequiredHandler.php file was changed.
    Inside the validate method:
  • A new argument was added to the addError method,'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • Another argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • The StopOnError.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • The RuleWithOptionsInterface usage was changed to DumpedRuleInterface.
  • The StringValue.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • The RuleWithOptionsInterface usage was changed to DumpedRuleInterface.
  • The message property was changed to use a placeholder for {Attribute}.
  • The StringValueHandler.php file was changed.
  • A new argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • The Subset.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • The SubsetHandler.php file was changed.
  • A new argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • The CountableLimitHandlerTrait.php file was changed.
  • A new argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • A new argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • The CountableLimitTrait.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • The SkipOnEmptyTrait.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • A new file TranslatedAttributesHandlerTrait.php was added.
  • The TrueValue.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • The RuleWithOptionsInterface usage was changed to DumpedRuleInterface.
  • The message property was changed to use a placeholder for {Attribute}.
  • The TrueValueHandler.php file was changed.
  • A new argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • The Url.php file was changed.
  • The RuleWithOptionsInterface import was changed to DumpedRuleInterface.
  • The RuleWithOptionsInterface usage was changed to DumpedRuleInterface.
  • The incorrectInputMessage property was changed to use a placeholder for {Attribute}.
  • The message property was changed to use a placeholder for {Attribute}.
  • The UrlHandler.php file was changed.
  • A new argument was added to the addError method, 'Attribute' => $context->getCapitalizedTranslatedAttribute().
  • The RuleInterface.php file was changed.
  • The getName method was removed.
  • The ValidationContext.php file was changed.
  • A new property $attributeLabel was added.
  • A new method setAttributeLabel was added.
  • A new method getAttributeLabel was added.
  • The getTranslatedAttribute method now returns a non-null string instead of a nullable string.
  • A new method getCapitalizedTranslatedAttribute was added.
  • The Validator.php file was changed.
  • The validate method now sets the attribute label from the data set if it is available.
  • The ConfigTest.php file was changed.
  • A test case for the translation category source was added.
  • The translation message assertion was changed to use a placeholder for {Attribute}.
  • The ObjectDataSetTest.php file was changed.
  • A test case for the getValidationPropertyLabels method was added.
  • The test case for hasAttribute was updated.
  • The ObjectWithLabelsProvider file was added.
* In `tests/Helper/ObjectParserTest.php`, the changes include adding and modifying assertions related to the `cache` and `labels` properties.
* In `tests/Helper/RulesDumperTest.php`, a new test case was added with a new `StubDumpedRule` class.
* In `tests/Helper/RulesNormalizerTest.php`, changes were made to `dataNormalize()` and `dataNormalizeList()`.
* In `tests/Rule/AtLeastTest.php`, a new test case was added to check if `$min` is greater than the number of attributes.
* In `tests/Rule/Base/RuleWithOptionsTestTrait.php`, `RuleWithOptionsInterface` was replaced with `DumpedRuleInterface`.
* In `tests/Rule/Base/RuleWithProvidedRulesTrait.php`, `RuleWithOptionsInterface` was replaced with `DumpedRuleInterface`.
* In `tests/Rule/BooleanValueTest.php`, changed the `getName()` method to return `BooleanValue::class` instead of `'boolean'`.
* In `tests/Rule/CallbackTest.php`, changed the `getName()` method to return `Callback::class` instead of `'callback'`.
  • The CompareTest.php file was modified. The following changes were made:
  • Line 23: Changed the value of $rule->getName() from 'compare' to Compare::class.
  • Lines 51-52: Changed the template of the 'message' array in the dataOptions() method from 'Value must be equal to "{targetValueOrAttribute}".' to '{Attribute} must be equal to "{targetValueOrAttribute}".'.
  • Lines 162-163: Changed the template of the 'message' array in the dataOptions() method from 'Value must be equal to "{targetValueOrAttribute}".' to '{Attribute} must be equal to "{targetValueOrAttribute}".'.
  • Lines 626-627: Updated the attribute name in the 'custom incorrect input message with parameters' test case from 'Attribute - ' to 'Attribute - value'.
  • Lines 682-683: Updated the attribute name in the 'custom greater than max message with parameters' test case from 'Attribute - ' to 'Attribute - value'.
  • Lines 706-707: Updated the attribute name in the 'custom message with parameters, capitalized attribute and target attribute set' test case from 'Attribute - ' to 'Attribute - Number'.
  • The CompositeTest.php file was modified. The following changes were made:
  • Line 31: Changed the value of $rule->getName() from 'composite' to Composite::class.
  • Lines 49-50: Updated the 'number' rule in the 'rules' array from 'Number' to Number::class.
  • Lines 54-56: Updated the 'number' rule in the 'rules' array from 'Number' to Number::class.
  • Lines 62-64: Updated the 'number' rule in the 'rules' array from 'Number' to Number::class.
  • Lines 71-73: Updated the 'number' rule in the 'rules' array from 'Number' to Number::class.
  • Lines 82-84: Updated the 'number' rule in the 'rules' array from 'Number' to Number::class.
  • Lines 99-100: Updated the 'test' rule in the 'rules' array from 'Test' to RuleWithoutOptions::class.
  • Lines 148-150: Updated the 'callback' rule in the 'rules' array from 'Callback' to Callback::class.
  • Lines 177-178: Updated the 'required' rule in the 'rules' array from 'Required' to Required::class.
  • Lines 242-243: Updated the 'callback' rule in the 'rules' array from 'Callback' to Callback::class.
  • Lines 327-331: Updated the 'class attribute' test case with a new 'rules' array.
  • The CountTest.php file was modified. The following changes were made:
  • Line 31: Changed the value of $rule->getName() from 'count' to Count::class.
  • Lines 42-43: Updated the 'lessThanMinMessage' array in the dataOptions() method to use the {min, plural, one{item} other{items}} format.
  • Lines 45-46: Updated the 'greaterThanMaxMessage' array in the dataOptions() method to use the {max, plural, one{item} other{items}} format.
  • Lines 48-49: Updated the 'notExactlyMessage' array in the dataOptions() method to use the {exactly, plural, one{item} other{items}} format.
  • Lines 55-56: Updated the 'lessThanMinMessage' array in the dataOptions() method to use the {min, number} format.
  • Lines 58-59: Updated the 'notExactlyMessage' array in the dataOptions() method to use the {exactly, number} format.
  • Lines 66-69: Updated the 'notExactlyMessage' array in the dataOptions() method to use the {exactly, number} format.
  • Lines 82-83: Updated the 'custom less than min message with parameters' test case to use 'Attribute - {Attribute}, attribute - {attribute}, type - {type}.' as the incorrect input message.
  • Lines 125-126: Updated the 'custom less than min message with parameters, attribute set' test case to use 'Attribute - {Attribute}, attribute - {attribute}, type - {type}.' as the incorrect input message.
  • Lines 156-157: Updated the 'less than min message with parameters' array in the dataValidationFailedLessThanMinWithParameters() method to use 'Attribute - {Attribute}, attribute - {attribute}, number - {number}.' as the message template.
  • Lines 169-171: Updated the 'greater than max message with parameters' test case to use 'Attribute - {Attribute}, attribute - {attribute}, number - {number}.' as the message template.
  • Lines 206-207: Updated the 'greater than max message with parameters, attribute set' test case to use 'Attribute - {Attribute}, attribute - {attribute}, number - {number}.' as the message template.
  • A new file DateTimeTest.php was added. This file contains tests for the DateTime rule.
  • Lines 16-17: Added InvalidArgumentException to the use statements.
  • Lines 20-139: Added tests for the DateTime rule with different configurations and inputs.
  • In EachTest.php, a new import statement was added for the class Yiisoft\Validator\Rule\StringValue.
  • In EachTest.php, the method testGetName() was modified to assert that the name of the rule instance is now Each::class instead of 'each'.
  • In EachTest.php, the dataOptions() method was modified to update the incorrect input message template for the rule.
  • In EachTest.php, the dataValidationFailed() method was modified to update the expected error messages for the rule.
  • In EachTest.php, a new test method testContextEachKey() was added to test the context each key parameter.
  • In EmailTest.php, the method testGetName() was modified to assert that the name of the rule instance is now Email::class instead of 'email'.
  • In EmailTest.php, the dataOptions() method was modified to update the incorrect input message template for the rule.
  • In EmailTest.php, the dataValidationFailed() method was modified to update the expected error messages for the rule.
  • In EqualTest.php, the method testGetName() was modified to assert that the name of the rule instance is now Equal::class instead of 'equal'.
  • In EqualTest.php, the dataOptions() method was modified to update the message template for the rule.
  • In GreaterThanOrEqualTest.php, the method testGetName() was modified to assert that the name of the rule instance is now GreaterThanOrEqual::class instead of 'greaterThanOrEqual'.
  • In GreaterThanOrEqualTest.php, the dataOptions() method was modified to update the message template for the rule.
  • In GreaterThanTest.php, the method testGetName() was modified to assert that the name of the rule instance is now GreaterThan::class instead of 'greaterThan'.
  • In GreaterThanTest.php, the dataOptions() method was modified to update the message template for the rule.
  • In InTest.php, the method testGetName() was modified to assert that the name of the rule instance is now In::class instead of 'inRange'.
  • In InTest.php, the dataOptions() method was modified to update the message template for the rule.
  • In JsonTest.php, the method testGetName() was modified to assert that the name of the rule instance is now Json::class instead of 'json'.
  • In JsonTest.php, the dataOptions() method was modified to update the incorrect input message template for the rule.
  • In JsonTest.php, the dataValidationFailed() method was modified to update the expected error messages for the rule.
* In the file `tests/Rule/LengthTest.php`:
- Added import `use Yiisoft\Validator\Tests\Rule\Base\DifferentRuleInHandlerTestTrait;`
- Modified the `testGetName` method to assert that the `getName()` method returns `Length::class`
- Modified the `dataOptions` method to change the following template strings:
  - `'This value must contain at least {min, number} {min, plural, one{character} other{characters}}.'` -> `'{Attribute} must contain at least {min, number} {min, plural, one{character} other{characters}}.'`
  - `'This value must contain at most {max, number} {max, plural, one{character} other{characters}}.'` -> `'{Attribute} must contain at most {max, number} {max, plural, one{character} other{characters}}.'`
  - `'This value must contain exactly {exactly, number} {exactly, plural, one{character} other{characters}}.'` -> `'{Attribute} must contain exactly {exactly, number} {exactly, plural, one{character} other{characters}}.'`
  - `'The value must be a string.'` -> `'{Attribute} must be a string.'`
- Modified the `dataValidationPassed` method to use different values for testing
- Modified the `dataValidationFailed` method to change the following template strings:
  - `'The value must be a string.'` -> `'Value must be a string.'`
  - `'This value must contain at least 10 characters.'` -> `'Value must contain at least 10 characters.'`
  - `'Min - {min}, attribute - {Attribute}, number - {number}.'` -> `'Min - {min}, attribute - {Attribute}, number - {number}.'`
  - `'Max - {max}, attribute - {attribute}, number - {number}.'` -> `'Max - {max}, attribute - {attribute}, number - {number}.'`
  - `'Exactly - {exactly}, attribute - {attribute}, number - {number}.'` -> `'Exactly - {exactly}, attribute - {Attribute}, number - {number}.'`
- Modified the `testIntegerEmptyPattern` method to change the assertion message template string `'Value must be empty.'` -> `'{Attribute} must be empty.'`
* In the file `tests/Rule/LessThanOrEqualTest.php`, modified the `testGetName` method to assert that the `getName()` method returns `LessThanOrEqual::class`.
* In the file `tests/Rule/LessThanTest.php`, modified the `testGetName` method to assert that the `getName()` method returns `LessThan::class`.
* In the file `tests/Rule/NotEqualTest.php`, modified the `testGetName` method to assert that the `getName()` method returns `NotEqual::class`.
* In the file `tests/Rule/NumberTest.php`:
- Modified the `testGetName` method to assert that the `getName()` method returns `Number::class`.
- Modified the `dataOptions` method to change the following template strings:
  - `'Value must be a number.'` -> `'{Attribute} must be a number.'`
  - `'Value must be no less than {min}.'` -> `'{Attribute} must be no less than {min}.'`
  - `'Value must be no greater than {max}.'` -> `'{Attribute} must be no greater than {max}.'`
  - `'Value must be a number.'` -> `'{Attribute} must be a number.'`
  - `'Value must be no less than {min}.'` -> `'{Attribute} must be no less than {min}.'`
  - `'Value must be no greater than {max}.'` -> `'{Attribute} must be no greater than {max}.'`
* In the file `tests/Rule/OneOfTest.php`:
- Modified the `testGetName` method to assert that the `getName()` method returns `OneOf::class`.
- Modified the `dataOptions` method to change the following template strings:
  - `'The value must be an array or an object.'` -> `'{Attribute} must be an array or an object.'`
  - `'The data must have at least 1 filled attribute.'` -> `'Exactly 1 attribute from this list must be filled: {attributes}.'`
- Modified the `dataValidationFailed` method to change the following template strings:
  - `'The value must be an array or an object.'` -> `'Value must be an array or an object.'`
  - `'Attribute - {attribute}, type - {type}.'` -> `'Attribute - {attribute}, type - {Type}.'`
  - `'Attribute - {attribute}.'` -> `'Attributes - {attributes}.'`
- Modified the `dataValidationFailed` method to change the assertion message template string `'The data must have at least 1 filled attribute.'` -> `'Exactly 1 attribute from this list must be filled: {attributes}.'`
  • In tests/Rule/RegexTest.php, the Regex::getName() method now returns Regex::class. The incorrectInputMessage and message properties have been updated to use placeholders {Attribute} in their templates.
  • In tests/Rule/RequiredTest.php, the Required::getName() method now returns Required::class. The message property has been updated to use the placeholder {Attribute} in its template. The notPassedMessage property has been renamed to getNotPassedMessage(). The EmptyCondition\WhenNull import has been moved to directly below the RequiredHandler import.
  • In tests/Rule/RuleWithBuiltInHandler.php, the getName() method has been removed.
  • In tests/Rule/StopOnErrorTest.php, the StopOnError::getName() method now returns StopOnError::class. The message property has been updated to use the placeholder {Attribute} in its template.
  • In tests/Rule/StringValueTest.php, the StringValue::getName() method now returns StringValue::class. The message property has been updated to use the placeholder {Attribute} in its template.
  • In tests/Rule/SubsetTest.php, the Subset::getName() method now returns Subset::class. The incorrectInputMessage and message properties have been updated to use placeholders {Attribute} in their templates.
  • In tests/Rule/TrueValueTest.php, the TrueValue::getName() method now returns TrueValue::class. The message and incorrectInputMessage properties have been updated to use placeholders {Attribute} in their templates.
* The file `tests/Rule/UrlTest.php` had several changes. 
- The line `$this->assertSame('url', $rule->getName());` was changed to `$this->assertSame(Url::class, $rule->getName());`.
- Multiple occurrences of incorrect input and message templates were changed from `'The value must be a string.'` and `'This value is not a valid URL.'` to `'Value must be a string.'` and `'Value is not a valid URL.'`.
- The line with `['' => ['The value must be a string.']]` was changed to `['' => ['Value must be a string.']]`.
- The line with `['' => ['This value is not a valid URL.']]` was changed to `['' => ['Value is not a valid URL.']]`.
* The file `tests/Support/Data/AtLeastDto.php` had several changes. 
- The class now implements `AttributeTranslatorProviderInterface`.
- Added a `getAttributeLabels()` method that returns an array of attribute labels.
- Added a `getAttributeTranslator()` method that returns an instance of `ArrayAttributeTranslator` using the attribute labels.
* The file `tests/Support/Data/ObjectForTestingCache1.php` had several changes. 
- Added an `#[Label('d')]` attribute above the private property `$c`.
* The file `tests/Support/Data/ObjectForTestingDisabledCache.php` had several changes. 
- Added an `#[Label('label')]` attribute above the private property `$c`.
* The file `tests/Support/Data/ObjectWithLabelsProvider.php` is a new file that was added.
* The file `tests/Support/Data/OneOfDto.php` had several changes. 
- The class now implements `AttributeTranslatorProviderInterface`.
- Added a `getAttributeLabels()` method that returns an array of attribute labels.
- Added a `getAttributeTranslator()` method that returns an instance of `ArrayAttributeTranslator` using the attribute labels.
* The file `tests/Support/Rule/CustomUrlRuleSet.php` had several changes. 
- Removed the `getName()` method from the class.
* The file `tests/Support/Rule/NotNullRule/NotNull.php` had a change. 
- Removed the `getName()` method from the class.
* The file `tests/Support/Rule/RuleWithCustomHandler.php` had a change. 
- Removed the `getName()` method from the class.
* The file `tests/Support/Rule/RuleWithoutOptions.php` had a change. 
- Removed the `getName()` method from the class.
* The file `tests/Support/Rule/StubRule/StubRuleWithOptions.php` was renamed to `tests/Support/Rule/StubRule/StubDumpedRule.php`.
* The file `tests/TestEnvironments/Php81/Rule/NestedTest.php` had several changes. 
- Changed the error messages for `'object.number'` from `'Value must be no greater than 7.'` to `'Number must be no greater than 7.'`.
* The file `tests/ValidationContextTest.php` had several changes. 
- Added a `testSetAttributeLabel()` method that tests the `setAttributeLabel()` method on the `ValidationContext` class.
- Added a `testSetAttributeLabelWithTranslator()` method that tests the `setAttributeLabel()` method with an `AttributeTranslator` on the `ValidationContext` class.

@vjik vjik marked this pull request as ready for review April 4, 2024 12:21
@vjik vjik requested a review from a team April 4, 2024 12:21
@vjik vjik added the status:code review The pull request needs review. label Apr 4, 2024
@vjik vjik merged commit fe63447 into master Apr 5, 2024
24 of 27 checks passed
@vjik vjik deleted the merge-1.x branch April 5, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants