Integrating with Riot

This page will help you integrate FormValidation with the Riot library.

For the sake of simplicity, we are about to validate a simple login form with just two fields to input the username and password:

Bundling the library

First of all, you need to look at the following guide to see how we can bundle FormValidation with popular bundlers:

Creating a FormValidation instance

The best place to initialize a FormValidation instance is inside the component's onMounted event:

Using the plugins

In order to use the plugins, we need to import them:

Now the FormValidation instance is ready, you can listen on the events or call API:

Registering validator

You don't need to follow this section if you are using a popular validator. The popular validator is ready when you import the FormValidation's core:

In the other cases, you have to use the registerValidator() method to let the library knows where it can find a special or custom validator:

Destroying FormValidation instance

Riot component triggers the onBeforeUnmount event when it's removed from page or not used anymore. It's the time to destroy our FormValidation instance by using the destroy() method:

More examples