Class: RegexValidator

sogv.RegexValidator

Validates that a value matches a regular expression.

new sogv.RegexValidator (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: ['regex', 'regexp'].

options Object The description of the required options.
Example
var validator = new sogv.RegexValidator(data, {pattern: 'regular expression'});
if (false === validator.isValid()) {
     validator.errors().first();
}

Extends

Members

data * inherited

Data that needs to be validated.

lang String overrides

Language of messages.

match Boolean

If true (or not set), this validator will pass if the given string matches the given pattern regular expression.

However, when this option is set to false, the opposite will occur: validation will pass only if the given string does not match the pattern regular expression.

Default: true.

message String

This is the message that will be shown if this validator fails.

Default: "This value is not valid."

You can use the following parameters in this message:

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

normalize Boolean

Normalizer string before validate (trim, etc.).

Default: false

pattern String

This required option is the regular expression pattern that the input will be matched against.

By default, this validator will fail if the input string does not match this regular expression.

However, if match is set to false, then validation will fail if the input string does match this pattern.

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