Vee-validate on prime vue #4786
yogendrarr
started this conversation in
General
Replies: 1 comment
-
I was able to use ChatGPT and it suggested wrapping
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i am using primevue multiselect
<MultiSelect class="w-full" optionLabel="allocationAlgorithmName" optionValue="allocationAlgorithmId" id="algorithms" v-model="event.algorithm" display="chip" :options="algorithmOptions" placeholder="Select allocation algorithm" /> <small id="email-help" class="text-red-600">{{ errors.algorithms }}</small>
Below is script in vue 3 comp api
import { useForm } from 'vee-validate'; import * as yup from 'yup'; let event = ref({ // posts related data will be saved in this array advertisementPosts: [], advertisementId : null, algorithm:[], advertisementPosts:[] });
`const schema = yup.object({
type: yup.string().required().label('Advertisement'),
algorithms:yup.array().min(1, "At least one option is required").required().label('Algorithms'),
posts :yup.array().min(1, "At least one option is required").required().label('Advertisement Post')
});
const {handleSubmit, resetForm, errors } = useForm({
validationSchema: schema,
initialValues: event
});
const onSubmit = handleSubmit((values) => {
console.log('Submitted with', values);
});`
validation not working with objcts how to do this . please somebody explain this..!
Beta Was this translation helpful? Give feedback.
All reactions