laminas/laminas-validator

Enum-Validator

reinfi opened this issue · 4 comments

Feature Request

I would like to have an enum validator.

Q A
New Feature yes
RFC no
BC Break may be, it depends

Summary

Like I have a value and if it is in the specific enum it is valid.

Of course this would be a php > 8.0 feature. So I just want to know if you're open for that or if it is not in the scope of this package.

I you're open for it I will try to add a pull request :-)

Perhaps just an expansion of the InArray validator for PHP > 8.1?

Like adding an Enum Class as Haystack?

Would make it a bit complicated to differentiate and you need to mix types.

Maybe: let's start with a proposal patch though, so go for it 💪

Please test it 😁

public function setHaystack(array $haystack)

just to be sure, I will need to change that to something supporting array and enum values and need to add a PHP-Version check because there is still 8.0 support.