Initializing help system before first use

EntityValidator

Register and call validation functions on entities.

Method summary

name description
checkValue Check a value is valid for a given entity.
getValidator Get the validation function attached to an entity for a given dimension.
isBoolean Check if value is a boolean. Allows null and undefined as they are used to clear array elements.
isInteger Check if value is an integer. Allows null and undefined as they are used to clear array elements.
isReal Check if value is a real. Allows null and undefined as they are used to clear array elements.
removeValidator Remove the validation function attached to an entity for a given dimension.
setValidator Set a validation function on a model entity for a given dimension.

Methods

static checkValue ( entity, value, dimension, key ) → {Result}

Check a value is valid for a given entity and optionally a specific dimension. Base (primitive) type checking is performed if in the NORMAL_DATA dimension then custom validation is performed.

Parameters:
Name Type Argument Default Description
entity string | ModelEntity name or instance of the entity to validate against
value * The value to check
dimension insight.enums.EntityDataDimension optional  insight.enums.EntityDataDimension.NORMAL_DATA The data dimension to check data in
key Array.<*> optional  Array element key, if applicable
Returns:
Type Description
Result Validation result and message, if in error
Example
var result = insight.validation.EntityValidator.checkValue('INTEGER_ENTITY', 120);
Back to Top
static getValidator ( entity, dimension ) → {function|undefined}

Get the validation function attached to an entity for a given dimension.

Parameters:
Name Type Argument Default Description
entity string | ModelEntity name or instance of the entity
dimension insight.enums.EntityDataDimension optional  insight.enums.EntityDataDimension.NORMAL_DATA The data dimension
Returns:
Type Description
function | undefined The validator callback or undefined if not set
Example
insight.validation.EntityValidator.getValidator('MY_ENTITY')
Back to Top
static isBoolean ( value ) → {boolean}

Check if value is a boolean. Allows null and undefined as they are used to clear array elements.

Parameters:
Name Type Description
value
Returns:
Type Description
boolean
Example
insight.validation.EntityValidator.isBoolean(false); // returns true
Back to Top
static isInteger ( value ) → {boolean}

Check if value is an integer. Allows null and undefined as they are used to clear array elements.

Parameters:
Name Type Description
value
Returns:
Type Description
boolean
Example
insight.validation.EntityValidator.isInteger(0.45); // returns false
Back to Top
static isReal ( value ) → {boolean}

Check if value is a real. Allows null and undefined as they are used to clear array elements.

Parameters:
Name Type Description
value
Returns:
Type Description
boolean
Example
insight.validation.EntityValidator.isReal(0.45); // returns true
Back to Top
static removeValidator ( entity, dimension ) → {boolean}

Remove the validation function attached to an entity for a given dimension.

Parameters:
Name Type Argument Default Description
entity string | ModelEntity name or instance of the entity
dimension insight.enums.EntityDataDimension optional  insight.enums.EntityDataDimension.NORMAL_DATA The data dimension
Returns:
Type Description
boolean Whether the validator was removed or not
Example
insight.validation.EntityValidator.removeValidator('MY_ENTITY');
insight.validation.EntityValidator.getValidator('MY_ENTITY'); // returns null
Back to Top
static setValidator ( entity, validator, dimension ) → {boolean}

Set a validation function on a model entity for a given dimension. This will overwrite any existing validation on the entity except for basic type checking validation that is always applied.

Parameters:
Name Type Argument Default Description
entity string | ModelEntity name or instance of the entity to attach the validator
validator EntityValidatorCallback The validation function
dimension insight.enums.EntityDataDimension optional  insight.enums.EntityDataDimension.NORMAL_DATA The data dimension to attach the validator to
Returns:
Type Description
boolean Whether the validation function was stored
Example
insight.validation.EntityValidator.setValidator('MY_ENTITY', function (entityName, value, indices) {
     var result = new insight.validation.Result(false);
     result.errorMessage = 'Invalid value ' + value;
     return result;
});
Back to Top

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.