Class: InValidator

sogv.InValidator

The field under validation must be included in the given list of values.

new sogv.InValidator (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: ['in'].

options Object The description of the required options.
Example
var validator = new sogv.InValidator("Liam", [
  "Liam", "Noah", "William", "James", "Logan", "Benjamin", "Mason", "Elijah",
  "Oliver", "Jacob", "Lucas", "Michael", "Alexander", "Ethan", "Daniel",
  "Matthew", "Aiden", "Henry", "Joseph", "Jackson", "Samuel", "Sebastian",
  "David", "Carter", "Wyatt", "Jayden", "John", "Owen", "Dylan", "Luke"
]);
if (false === validator.isValid()) {
     validator.errors().first();
}

Extends

Members

choices Array

A required option - The field under validation must be included in the given list of values.

The input value will be matched against this array.

data * inherited

Data that needs to be validated.

lang String inherited

Language of error messages.

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