Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: optional labels for enums #17

Open
aidalgol opened this issue Apr 28, 2024 · 1 comment
Open

Proposal: optional labels for enums #17

aidalgol opened this issue Apr 28, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@aidalgol
Copy link

Is your proposal related to a problem? Please describe.
AshPyro.Enum looks ideal for my in-progress Phoenix app using Ash for resources, but one of my enum-type attributes represents New Zealand districts, the names of some of which are hyphenated, so the opinionated "humanized" labels will be incorrect.

Describe the solution you'd like
An optional syntax for providing a label for an enum value that would be used by humanize_enum/1, if provided, otherwise the current behaviour would be used.

Describe alternatives you've considered
Just using Ash.Type.Enum with functions on my enum module for now.

Express the proposal either with a change to resource syntax, or with a change to the pyro interface
Possible syntax suggested by @frankdugan3 on the Ash Discord server:

use AshPyro.Enum, values: [some_district: [label: "Some-District"]]

Additional context
Official New Zealand district names and maps

@aidalgol aidalgol added the enhancement New feature or request label Apr 28, 2024
@frankdugan3 frankdugan3 added the good first issue Good for newcomers label Apr 28, 2024
@frankdugan3
Copy link
Owner

I will eventually add this feature, along with better docs & testing. If I take too long to get around to it and you want to take a stab at a PR, feel free to give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants