Skip to content

[v4] How can I programmatically validate a group of fields? #3828

Answered by logaretm
jameshibbard asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry I missed this. I would say the best way to do this is with the composition API. Since you have access to validateField you can pretty much do what you want by calling it for each field you want to validate.

So something like this:

<script setup>
const { validateField } = useForm({
  // validation schema and other options ...
});

function validateGroup() {
  // rough example, use map and `promise.all` to be able to await this properly.
  ['name', 'email', 'password'].forEach(field => validateField(field));
}
</script>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jameshibbard
Comment options

@logaretm
Comment options

@jameshibbard
Comment options

Answer selected by jameshibbard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants