Class: IsbnValidator

sogv.IsbnValidator

This constraint validates that an International Standard Book Number (ISBN) is either a valid ISBN-10 or a valid ISBN-13.

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

options Object The description of the required options.
Example
var validator = new sogv.IsbnValidator(data);
if (false === validator.isValid()) {
     validator.errors().first();
}

Extends

Members

bothIsbnMessage String

The message that will be shown if the type option is null and the given value does not pass any of the ISBN checks.

Default: "This value is neither a valid ISBN-10 nor a valid ISBN-13."

You can use the following parameters in this message:

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

data * inherited

Data that needs to be validated.

isbn10Message String

The message that will be shown if the type option is isbn10 and the given value does not pass the ISBN-10 check.

Default: "This value is not a valid ISBN-10."

You can use the following parameters in this message:

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

isbn13Message String

The message that will be shown if the type option is isbn13 and the given value does not pass the ISBN-13 check.

Default: "This value is not a valid ISBN-13."

You can use the following parameters in this message:

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

lang String inherited

Language of error messages.

message String

The message that will be shown if the value is not valid. If not null, this message has priority over all the other messages.

Default: null

You can use the following parameters in this message:

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

type String

The type of ISBN to validate against. Valid values are isbn10, isbn13 and null to accept any kind of ISBN.

Default: null

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