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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird error 馃槄 #16

Closed
devbyray opened this issue Jul 26, 2023 · 3 comments
Closed

Weird error 馃槄 #16

devbyray opened this issue Jul 26, 2023 · 3 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@devbyray
Copy link

I love the idea of your library, so let's try some things out to see how it works.

But I found some errors that didn't give me a clear error message; maybe something needs to be fixed on my side or your side.

I created a Runkit example so you can check it out: https://runkit.com/devbyrayray/testing-valibot

@fabian-hiller
Copy link
Owner

fabian-hiller commented Jul 26, 2023

I think that dateOfBirth is the problem. The value should be string([isoDateTime()]). In my editor, TypeScript also gives me a type error at this point with your code.

const UserProfileSchema = object({
  email: string([email()]),
  firstName: string([minLength(1)]),
  lastName: string([minLength(1)]),
  dateOfBirth: isoDateTime(),
});

@fabian-hiller fabian-hiller self-assigned this Jul 26, 2023
@fabian-hiller fabian-hiller added the invalid This doesn't seem right label Jul 26, 2023
@devbyray
Copy link
Author

Thanks, man! That works 馃憤

If I want my lastName also to have a maximum, is this the way to do it? string([minLength(1), maxLength(10)])

@fabian-hiller
Copy link
Owner

Yes, that looks correct. You can also add your own error messages if you want:

string([minLength(1, 'Please enter your last name.'), maxLength(10, 'Please limit your input to 10 characters.')])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants