Skip to content

Add Zod's built-in string transformations as field attributes #981

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

Merged
merged 5 commits into from
Feb 3, 2024

Conversation

simonedelmann
Copy link
Contributor

As discussed in Discord:

Zod has built-in string transformations .trim() / .toUpperCase() / .toLowerCase()

This PR adds data validation attributes @trim / @upper / @lower to ZModel:

model User {
    // ...
    name String @length(min: 1) @trim
    slug String @lower
    heroText String @upper
}

@simonedelmann simonedelmann marked this pull request as ready for review February 2, 2024 13:45
@ymc9 ymc9 changed the base branch from main to dev February 3, 2024 08:35
@ymc9
Copy link
Member

ymc9 commented Feb 3, 2024

Thank you for working on it @simonedelmann ! I'm merging it to dev and will include it in the next release (around 2/15). I'll also check if more changes are needed to make it effective for Prisma create/update operations.

@ymc9 ymc9 merged commit dde1931 into zenstackhq:dev Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants