-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
How to use global validator for useFieldArray #5000
rogerluo410
started this conversation in
General
-
Use global validator, not yup, how to validate the object's attribute in the list,
<tr v-for="(option, index) of editQuestionParamOptions" :key="index"> <td :class="errors[`options.${index}.name`] ? 'is_error' : ''"> <input v-model="(option.value as OptionProps).name" :disabled="disabled()" type="text" name="option test" @change="checkOptions()" /> <p v-show="errors[`options.${index}.name`]" class="m_form_error"> {{ errors[`options.${index}.name`] }} </p> </td> </tr> const { errors, resetForm, validate, setFieldValue } = useForm({ validationSchema: { name: "required|max:255|first_deny:*,Q|string_deny:[,]|comma_deny", options: { name: "required|max:255|string_deny::" } } }); const { value: editQuestionParamNameValue } = useField<string>("name"); const { remove: optionRemove, push: optionAdd, fields: editQuestionParamOptions, } = useFieldArray<OptionProps>("options");
I want to set validationSchema like this, the options.name should be validated:
validationSchema: { name: "required|max:255|first_deny:*,Q|string_deny:[,]|comma_deny", options: { name: "required|max:255|string_deny::" } }
But, not work. It throws out "Uncaught (in promise) Error: No such validator 'name' exists."
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment