Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
muffe authored Aug 5, 2022
1 parent a9a466b commit d02008e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# enum-constraint
A Symfony Validator constraint that validates of given strings a valid cases in a given PHP 8 Enum

```
enum ContactCategory: string
{
case Child = 'Child';
case Grandchild = 'Grandchild';
}
use Muffe\EnumConstraint\Constraints\Enum;
#[
Enum(
enumType: ContactCategory::class,
)
]
public ?string $category = null;
```

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.

```
use Muffe\EnumConstraint\Constraints\Enum;
#[
Enum(
enumType: ContactCategory::class,
multiple: true
)
]
public ?array $categories = null;
```
Also supports validating multiple given values

0 comments on commit d02008e

Please sign in to comment.