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

Using enums as a record key #134

Closed
abd2561024 opened this issue Sep 1, 2023 · 2 comments
Closed

Using enums as a record key #134

abd2561024 opened this issue Sep 1, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request priority This has priority

Comments

@abd2561024
Copy link
Contributor

I need to migrate from follow Zod construction with Record

const MyRecordSchema = z.record(z.nativeEnum(KEY_NAME), z.array(z.string().min(1)).nonempty());

If I change this construction to

const MyRecordSchema = record(nativeEnum(KEY_NAME), array(string([minLength(1)]), [minLength(2)]));

I got follow TS error

Types of property  schema  are incompatible.
Type  "native_enum"  is not assignable to type  "string" 

So any idea how to fix this error pls? If I ignore it and run parse, it works correctrly, and return error when I try to pass incorrect key (not from KEY_NAME object).

@fabian-hiller
Copy link
Owner

Thank you very much for your hint. I will try to fix that next week. Basically I just need to update the types. As you wrote correctly, it already works technically.

@fabian-hiller fabian-hiller self-assigned this Sep 1, 2023
@fabian-hiller fabian-hiller added enhancement New feature or request priority This has priority labels Sep 1, 2023
@fabian-hiller
Copy link
Owner

v0.15.0 is now available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority This has priority
Projects
None yet
Development

No branches or pull requests

2 participants