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

Extra validation on generated output - e.g minlength of string #80

Open
outofthisworld opened this issue Apr 25, 2023 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@outofthisworld
Copy link

outofthisworld commented Apr 25, 2023

Bug description

Given a user model like

model User{
   email string
}

produces the generated class

const UserCreateOneSchema = z.object({ email: z.string() });

However, using validation against this schema on a formSubmit coerces undefined into an empty string, or inputs with no data become empty strings and this validation succeeds.

Ideally email isn't: ''

Would be handy to have some sort of way of specify minLength

How to reproduce

  1. validate using schema in a form onsubmit method

Expected behavior

  1. Some way of specifying validation requirements

Prisma information

Prisma v4

Environment & setup

macOs

Prisma Version

4

@omar-dulaimi omar-dulaimi added the enhancement New feature or request label Apr 28, 2023
@TalissonBento
Copy link

up 👍

@TalissonBento
Copy link

TalissonBento commented Aug 18, 2024

I suggest something like this:

model User{
   email string /// @zod.min(3, 'too short').max(18, 'too long')
}

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

No branches or pull requests

3 participants