Class: ValidatorError

Oracle® JavaScript Extension Toolkit (JET)
5.0.0

E90577-01

QuickNav

ValidatorError

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

Constructor

new ValidatorError(summary, detail)

Constructs a ValidatorError instance from a summary and detail
Parameters:
Name Type Description
summary string a localized String that provides a summary of the error
detail string a localized String that provides a detail of the error
Example

throw new oj.ValidationError from custom validator's validate method

 // A custom validator whose validate method ensures that the value is not 'junk'.
 self.noJunkValidator = {
 'validate' : function (value)
 {
   value = value + "";
   if (value && value.toLowerCase()  === "junk")
   {
     throw new oj.ValidatorError("Invalid value", "You cannot enter a value that is 'junk'!!");
   }
   return true;
   }
 };

Methods

getMessage() → {Object}

Returns an Object that duck-types oj.Message which is an Object with summary, detail, and severity properties. The severity is oj.Message.SEVERITY_LEVEL['ERROR']
Returns:
an Object that duck-types oj.Message which is an Object with summary, detail, and severity properties. The severity is oj.Message.SEVERITY_LEVEL['ERROR']
Type
Object
Example

get the oj.ValidationError that was thrown and get the message

var ojmessage = valError.getMessage();
var severity = ojmessage['severity'] || oj.Message.SEVERITY_LEVEL['ERROR'];
var summary = ojmessage['summary'];
var detail = ojmessage['detail'];