membrane-php / membrane-core

Membrane is a general purpose input validation library, supports both PHP Attributes and OpenAPI specifications
Other
1 stars 2 forks source link

Ability to filter values to enum types #183

Closed charjr closed 1 month ago

charjr commented 1 month ago

Membrane handles the enum keyword in OpenAPI using validators like Contained but this is different from handling actual PHP enums.

charjr commented 1 month ago

@carnage How should we handle this?

  1. If we base it off value we would be unable to support UnitEnums without a value.

  2. If we base it off name we can support all enums in a consistent manner.

  3. We allow both, with two filters: ToEnumFromName and ToEnumFromValue which could be used depending on preference.