Class: RangeValidator

sogv.RangeValidator

Validates that a given number or Date object is between some minimum and maximum.

new sogv.RangeValidator (data, options, optionRules, lang, internal)

Create a new Validator.

Name Type Description
data * The data which needs to be validated.
options Object The setting options
optionRules Object The validation rules for setting options.
lang String The language used by the application. Default: "en".
internal Boolean If this parameter is true, it means, that validation called from core.
Properties:
Name Type Description
alias Array

The aliases for the current validator.

They could be used in the short validation format.

Defined aliases: ['range'].

options Object The description of the required options.
Example
var validator = new sogv.RangeValidator('1991-12-17T03:24:00', {"min":"1990-12-17T03:24:00","max":"1995-12-17T03:24:00"});
if (false === validator.isValid()) {
     validator.errors().first();
}

Extends

Members

data * inherited

Data that needs to be validated.

invalidMessage String

The message that will be shown if the underlying value is not a number.

Default: "This value should be a valid number."

You can use the following parameters in this message:

Parameter Description
%%value%% The current (invalid) value

lang String inherited

Language of error messages.

max Number | String | Date

This required option is the "max" value. Validation will fail if the given value is greater than this max value.

maxMessage String

The message that will be shown if the underlying value is more than the max option.

Default: "This value should be %%limit%% or less."

You can use the following parameters in this message:

Parameter Description
%%limit%% The upper limit
%%value%% The current (invalid) value

min Number | String | Date

This required option is the "min" value. Validation will fail if the given value is less than this min value.

minMessage String

The message that will be shown if the underlying value is less than the min option.

Default: "This value should be %%limit%% or more."

You can use the following parameters in this message:

Parameter Description
%%limit%% The lower limit
%%value%% The current (invalid) value

notInRangeMessage String

The message that will be shown if the underlying value is less than the min option or greater than the max option.

Default: "This value should be between %%min%% and %%max%%."

You can use the following parameters in this message:

Parameter Description
%%max%% The upper limit
%%min%% The lower limit
%%value%% The current (invalid) value

Methods

errors ()sogv.Error inherited

Return error errors

Returns:
Type Description
sogv.Error Error messages

isValid ()Boolean inherited overrides

Check if data valid.

Returns:
Type Description
Boolean Validation status