onvalidation
Fires when the form's validation result changes - from valid to invalid, invalid to valid, or when the set of field errors changes.
Usage
onvalidation?: (ev: {
errors: Record<string, { errorType: string }> | null;
values: Record<string, any>;
}) => void;
| Field | Type | Description |
|---|---|---|
errors | Record<string, { errorType: string }> | null | Map of field key to error, or null when all values are valid. |
values | Record<string, any> | Current values snapshot. |
errorType is "required" for an empty required field or "validation" for a failed custom rule.
Example
<script setup>
import { Editor } from "@svar-ui/vue-editor";
function onvalidation(ev) {
if (ev.errors) {
for (const key in ev.errors) {
console.log(`${key}: ${ev.errors[key].errorType}`);
}
}
}
</script>
<template>
<Editor :items="items" :values="values" :onvalidation="onvalidation" />
</template>