Effect-TS / effect

An ecosystem of tools to build robust applications in TypeScript
https://effect.website
MIT License
7.74k stars 246 forks source link

Schema const enums #3847

Closed decoursin closed 1 month ago

decoursin commented 1 month ago

What is the problem this feature would solve?

Zod supports these fixed set enums which are like arrays declared with the const keyword. I was hoping Effect's Schema could also.

What is the feature you are proposing to solve the problem?

Support for const arrays.

What alternatives have you considered?

I have tried Schema.Enums which doesn't work.

jessekelly881 commented 1 month ago

I believe you want

Schema.Literal("a", "b") // or Schema.Literal(...arr)
decoursin commented 1 month ago

@jessekelly881 Thanks. The Schema.Literal(...arr) works. Sorry for the inconvenience. I suppose an example might be good, but IDK up to you!