Class: Validator

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

Signature:

class Validator<V>

QuickNav


Validator

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

Module usage

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

Javascript Import Format
define(['ojs/ojvalidation-base'], function(validationBase) {
 // Application should call API on validationBase.Validator 
})
Typescript Import Format
//This class is not exported from module and can not be accessed in runtime.
//However to enable typechecking and ducktyping, you can access it as an interface.
import {Validator} from "ojs/ojvalidation-base";

//To access this type in your code,
class MyClass implements Validator{
//or,
let myVariable: Validator;
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.

Constructor

(abstract) new Validator(options)

Parameters:
Name Type Argument Description
options Object <optional>
An object which contains the options for the validator

Methods

getHint(): string|null

Returns a hint that describes the validator rule.
Returns:
a hint string or null
Type
string | null

validate(value) → {void}

Validates the value. The function typically returns if the validation passes and throws an error if it fails.
Parameters:
Name Type Description
value V to be validated
Throws:
if validation fails
Type
Error
Returns:
Type
void
Deprecated Return Types:
Since Value Description
6.2.0 any This currently returns any type if successful, like boolean, original value, or nothing. In v8.0 it will return nothing if successful.