Skip to content

Commit

Permalink
Add support for enum on RangeValidator's client validation
Browse files Browse the repository at this point in the history
  • Loading branch information
glpzzz authored Jan 27, 2025
1 parent e83339a commit 17d7e68
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions framework/validators/RangeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ public function getClientOptions($model, $attribute)
{
$range = [];
foreach ($this->range as $value) {
if (version_compare(PHP_VERSION, '8.1.0') >= 0) {
if ($value instanceof \BackedEnum) {
$value = $value->value;
} elseif ($value instanceof \UnitEnum) {
$value = $value->name;

Check warning on line 131 in framework/validators/RangeValidator.php

View check run for this annotation

Codecov / codecov/patch

framework/validators/RangeValidator.php#L127-L131

Added lines #L127 - L131 were not covered by tests
}
}

Check failure on line 133 in framework/validators/RangeValidator.php

View workflow job for this annotation

GitHub Actions / PHP_CodeSniffer

Whitespace found at end of line
$range[] = (string) $value;
}
$options = [
Expand Down

0 comments on commit 17d7e68

Please sign in to comment.