promise validator

Use Promise to validate value


Using with form field

* presents a required option. The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
message data-fv-promise___message String The error message
promise* data-fv-promise___promise String or Function The callback returns promise instance

The promise option must be a function or the name of function which returns a Promise as following:

Basic Example

The following form asks user to upload an avatar which both width and height must be less than 300px.


Use the file validator if you want to validate size of an image

They can be determined using Promise as seen in the following snippet:

When the field is validated completely, we can get the custom data stored in the result's meta:

Related validators

The following validators might be useful to you.