Class: UrlValidator

sogv.UrlValidator

Validates that a value is a valid URL string.

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

options Object The description of the required options.
Example
var validator = new sogv.UrlValidator(data);
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 message is shown if the URL is invalid.

Default: "This value is not a valid URL."

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.

protocols Array

The protocols considered to be valid for the URL. For example, if you also consider the ftp:// type URLs to be valid, redefine the protocols array, listing http, https, and also ftp. Default: ['http', 'https', 'ftp']

relativeProtocol Boolean

If true, the protocol is considered optional when validating the syntax of the given URL. This means that both http:// and https:// are valid but also relative URLs that contain no protocol (e.g. //example.com). Default: false.

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