Interface: AsyncValidator

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

Signature:

interface AsyncValidator<V>

QuickNav

Fields


PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

AsyncValidator

Version:
  • 7.1.0
Since:
  • 5.2.0
Module:
  • ojvalidation-base

Module usage

See JET Module Loading for an overview of module usage within JET.

Typescript Import Format
//To use this interface, import as below.
import {AsyncValidator} from "ojs/ojvalidation-base";
Generic Parameters
ParameterDescription
VType of value to be validated

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.

The oj.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)>

PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

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

Methods

validate(value: V): Promise<void>

PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

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 oj.IntlConverterUtils.getConverterInstance(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>