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

Use conditional Validation Schema #4769

Closed
zee-shan000 opened this issue Jun 2, 2024 · 3 comments
Closed

Use conditional Validation Schema #4769

zee-shan000 opened this issue Jun 2, 2024 · 3 comments

Comments

@zee-shan000
Copy link

Here is my code.
const { handleSubmit } = useForm({ validationSchema: { ...operating, ...digest } }),

I want operating to work on some conditions not always.

Originally posted by @zee-shan000 in #4765

@logaretm
Copy link
Owner

logaretm commented Jun 2, 2024

use computed form schemas, check the docs here.

@logaretm logaretm closed this as completed Jun 2, 2024
@zee-shan000
Copy link
Author

@logaretm Not working with useForm composable.

here is my code.

const validationSchemaa = computed(() => {
  if (parentType.value === parentFinancingRequests.opex) {
    return {
      duration: yup
        .string()
        .required('error'),
      amount: yup
        .string()
        .required('error')
    }
  } else {
    return {}
  }
})

const { handleSubmit, values } = useForm({
  validationSchema: yup.object(validationSchemaa.value)
})

@trojanyao
Copy link

The same issue with @zee-shan000

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

No branches or pull requests

3 participants