[news] Yii Validator 2.0


Major version of Yii Validator were tagged.

  • Add the Each::PARAMETER_EACH_KEY validation context parameter that available during Each rule handling and containing the current key
  • Include attribute name in error messages when it's present
  • Add PHP attribute that sets property label for usage in error messages
  • Add InEnum rule
  • Change "attribute" to "property" in class/trait/method/variable/placeholder names
  • Change type of $escape argument in Error::getValuePath() from bool|string|null to string|null
  • List translated attributes in error message for OneOf and AtLeast rules
  • Fix meaning of error message in OneOf rule
  • Improve meaning and use pluralization in error message for OneOf and AtLeast rules
  • Disallow $min greater than amount of $attributes in AtLeast configuration
  • Move getName() method from RuleInterface to RuleWithOptionsInterface
  • Rename RuleWithOptionsInterface to DumpedRuleInterface
  • Use FQCN as a name for built-in rules during export with RulesDumper
  • Use FQCN as a name for rules not implementing DumpedRuleInterface during export with RulesDumper
  • Change type of $skipOnEmpty argument in rules' constructors from mixed to bool|callable|null
  • Change type of $rule argument in RuleHandlerInterface::validate() from object to RuleInterface
  • Rename AtLeast rule to FilledAtLeast and OneOf rule to FilledOnlyOneOf
  • Add type to error messages related with incorrect input
  • Use json_validate() built-in PHP function in JsonHandler if code is run with PHP 8.3
  • Improve psalm annotations in Result class
  • Add German translation
  • Simplify validation of JSON in JsonHandler using built-in PHP functions for PHP versions below 8.3
  • Raise the minimum version of PHP to 8.1
  • Refactor Result::add(): took array_merge() out of the foreach
  • Make parameter $rules in RulesNormalizer::normalize() optional
  • Make Json::$message a bit more clear
  • Fix property name usage in error messages of rules in Nested rule
  • Rules provided by data object PHP attributes were not used in RulesNormalizer::normalize()
  • Fix wrong value for type parameter for Each::$incorrectInputKeyMessage

See upgrading instructions with notes about upgrading package in your application to this major version.