/**
* Copyright (c) 2014, Oracle and/or its affiliates.
* All rights reserved.
*/
/**
* Validator Contract
*/
/**
* @constructor
* @export
* @since 0.6
*
*/
oj.Validator = function()
{
this.Init();
};
// Subclass from oj.Object
oj.Object.createSubclass(oj.Validator, oj.Object, "oj.Validator");
/**
* Initializes validator instance with the set options
* @export
*/
oj.Validator.prototype.Init = function()
{
oj.Validator.superclass.Init.call(this);
};
/**
* Vaidates the value.
*
* @param {Object} value to be validated
* @return {*} a boolean true if validation passes.
* @throws Error if validation fails
* @export
*/
oj.Validator.prototype.validate = function (value) {
oj.Assert.failedInAbstractFunction();
};
/**
* Returns a hint that describes the validator rule.
* @returns {*} a hint string or null
* @export
*/
oj.Validator.prototype.getHint = function ()
{
oj.Assert.failedInAbstractFunction();
};
// ValidatorError
/**
* Constructs a ValidatorError instance from a summary and detail
*
* @param {string} summary a localized String that provides a summary of the error
* @param {string} detail a localized String that provides a detail of the error
* @constructor
* @export
*/
oj.ValidatorError = function (summary, detail)
{
var message = new oj.Message(summary,
detail,
oj.Message.SEVERITY_LEVEL['ERROR']);
this.Init(message);
};
oj.ValidatorError.prototype = new Error();
/**
* Initializes the instance.
* @param {Object} message an instance of oj.Message
* @export
*/
oj.ValidatorError.prototype.Init = function (message)
{
var detail = message['detail'], summary = message['summary'];
this._message = message;
// so browser can get to e.name and e.message
this.name = 'Validator Error';
this.message = detail || summary;
};
/**
* Returns an instance of oj.Message.
*
* @returns {Object} instance of oj.Message
* @export
*/
oj.ValidatorError.prototype.getMessage = function ()
{
return this._message;
};
Source: src/main/javascript/oracle/oj/ojvalidation/Validator.js
Oracle® JavaScript Extension Toolkit (JET)
1.1.2
E65298-01