Skip to content

Commit d02008e

Browse files
authored
Create README.md
1 parent a9a466b commit d02008e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# enum-constraint
2+
A Symfony Validator constraint that validates of given strings a valid cases in a given PHP 8 Enum
3+
4+
```
5+
enum ContactCategory: string
6+
{
7+
case Child = 'Child';
8+
case Grandchild = 'Grandchild';
9+
}
10+
11+
use Muffe\EnumConstraint\Constraints\Enum;
12+
13+
#[
14+
Enum(
15+
enumType: ContactCategory::class,
16+
)
17+
]
18+
public ?string $category = null;
19+
```
20+
21+
Validates that $category contains a string that is equal to the backed value of one of the given enum cases, or the name of the case if no backed values are given.
22+
23+
```
24+
use Muffe\EnumConstraint\Constraints\Enum;
25+
26+
#[
27+
Enum(
28+
enumType: ContactCategory::class,
29+
multiple: true
30+
)
31+
]
32+
public ?array $categories = null;
33+
```
34+
Also supports validating multiple given values

0 commit comments

Comments
 (0)