Class: IdenticalToValidator

sogv.IdenticalToValidator

Validates that a value is identical to another value, defined in the options.

This constraint compares using ===, so 3 and "3" are not considered equal.

new sogv.IdenticalToValidator (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: ['identical-to', 'identical', 'it'].

options Object The description of the required options.
Example
var validator = new sogv.IdenticalToValidator(data, {"value": "the value to compare to"});
if (false === validator.isValid()) {
     validator.errors().first();
}

Extends

Members

data * inherited

Data that needs to be validated.

lang String inherited

Language of error messages.

message String

This is the message that will be shown if the value is not identical.

Default: "This value should be identical to %%compared_value_type%% %%compared_value%%."

You can use the following parameters in this message:

Parameter Description
%%compared_value%% The expected value
%%compared_value_type%% The expected value type
%%value%% The current (invalid) value

value *

This option is required.

It defines the value to compare to.

It can be a string, number or object.

Methods

errors ()sogv.Error inherited

Return error errors

Returns:
Type Description
sogv.Error Error messages

isValid ()Boolean inherited

Check if data valid.

Returns:
Type Description
Boolean Validation status