Skip to content

Dynamic Rule Updates in vee-validate 4.5.11 with Vue 3 & TypeScript Not Working #4639

Answered by chaoowen
chaoowen asked this question in Q&A
Discussion options

You must be logged in to vote

I got inspiration from #4578,and found solution like:

const {
  value: inputValue,
  handleChange,
}: {
  value: Ref<InputValue>
  handleChange: (value: InputValue) => void
} = useField(
  props.name,
  computed(() => {
    const result = useFieldRules({
      rules: props.rules,
      required: props.required,
    })
    return result.validationRules.value
  })
)

However, it's not working if you set computed variable instead of putting whole computed inside useFieldRules.

// not working in this way
const { validationRules } = computed(() => {
    const { validationRules } = useFieldRules({
      rules: props.rules,
      required: props.required,
    })
    return validationRules.value
…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by chaoowen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant