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

optional string field with string min/max options set wrong meta in veevalidate #505

Closed
yudinmaxim opened this issue Apr 5, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@yudinmaxim
Copy link

I'm not sure if this is a valibot problem, but it could be.
Valibot version 0.27

I make a record of the scheme like this:

const deviceSchema = object({
  imsi: imsi(),
  imei: optional(string([
    minLength(1, 'Необходимо ввести IMEI'),
    minLength(15, 'IMEI должен быть не менее 15 цифр'),
  ])),
  description: optional(string()),
})

Next, I use the scheme in conjunction with veevalidate:

const { handleSubmit, meta, errors, defineField, resetForm } = useForm<tDevice>({
  validationSchema: toTypedSchema(deviceSchema),
})

And I get that meta does not have the correct flag if the imei does not meet the length requirements, despite the fact that the field is optional.

I assume that the scheme in which the optional field has length requirements (or others) does not work correctly.
But this is just a guess.

@fabian-hiller
Copy link
Owner

Feel free to try it out in our playground: https://valibot.dev/playground/

@fabian-hiller fabian-hiller self-assigned this Apr 5, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Apr 5, 2024
@yudinmaxim
Copy link
Author

Yes - this is problem with veevalidate
In valibot playground all looks OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants