Interface: AsyncValidator

Oracle® JavaScript Extension Toolkit (JET)
10.0.0

F32683-01

Since:
  • 5.2.0
Module:
  • ojvalidator-async

QuickNav

Fields

Description

The AsyncValidator interface is a duck-typing interface for creating asynchronous validators that can be set on the EditableValue (aka JET form) components that have the async-validators attribute.


Usage

Signature:

interface AsyncValidator<V>

Generic Parameters
ParameterDescription
VType of value to be validated
Typescript Import Format
//To use this interface, import as below.
import AsyncValidator= require("ojs/ojvalidator-async");

//To access this interface in your code:
declare class MyAsyncValidator implements AsyncValidator

For additional information visit:


The AsyncValidator interface is a duck-typing interface for creating asynchronous validators that can be set on the EditableValue (aka JET form) components that have the async-validators attribute.

Fields

hint :Promise.<(string|null)>

hint is an optional attribute. It is a Promise that resolves to the hint string or null.

Methods

validate(value: V): Promise<void>

A method that validates the value. The function returns a Promise that resolves to void if the validation passes or a Promise that rejects with an error if it fails. The error will be shown on the component.

It is recommended that you show the value you are validating in the error message because if the async operation takes a while, the user could be typing in a new value when the error message comes back and might be confused what value the error is for.

If you need to format the value for the error message, you can use e.g. for number new NumberConverter.IntlNumberConverter(converterOption) to get the converter instance, then call converter.format(value);

Parameters:
Name Type Description
value any to be validated
Returns:
A Promise that resolves to nothing if validation passes or rejects with an Error if validation fails.
Type
Promise.<void>