Class: LengthValidator

Oracle® JavaScript Extension Toolkit (JET)
2.0.0

E70325-01

QuickNav

oj. LengthValidator

Version:
  • 2.0.0
Since:
  • 0.7

Constructor

new LengthValidator(options)

Constructs a LengthValidator that ensures the value entered is within a given length.
Parameters:
Name Type Argument Description
options Object <optional>
an object literal used to provide:

Properties
Name Type Argument Description
min number <optional>
a number that is the minimum length of the value.
max number <optional>
a number that is the maximum length of the value.
hint Object <optional>
an optional object literal of hints to be used.
Properties
Name Type Argument Description
max string <optional>
a hint message to be used to indicate the allowed maximum. When not present, the default hint is the resource defined with the key oj-validator.length.hint.max.

Tokens:
{max} - the maximum

Usage:
Enter {max} or fewer characters

min string <optional>
a hint message to be used to indicate the allowed minimum. When not present, the default hint is the resource defined with the key oj-validator.length.hint.min.

Tokens:
{min} the minimum

Usage:
Enter {min} or more characters

inRange string <optional>
a hint message to be used to indicate the allowed range. When not present, the default hint is the resource defined with the key oj-validator.length.hint.inRange.

Tokens:
{min} the minimum

{max} - the maximum

Usage:
Enter between {min} and {max} characters

exact string <optional>
a hint message to be used, to indicate the exact length. When not present, the default hint is the resource defined with the key oj-validator.length.hint.exact.

Tokens:
{length} the length

Usage:
Enter {length} characters

messageDetail Object <optional>
an optional object literal of custom error messages to be used.
Properties
Name Type Argument Description
tooLong string <optional>
the detail error message to be used as the error message, when the length of the input value exceeds the maximum value set. When not present, the default detail message is the resource defined with the key oj-validator.length.messageDetail.tooLong.

Tokens:
{value} - value entered by the user
{max} - the maximum allowed value

Usage:
The {value} has too many characters. Enter {max} or fewer characters, not more.

tooShort string <optional>
the detail error message to be used as the error message, when the length of the input value is less the minimum value set. When not present, the default detail message is the resource defined with the key oj-validator.length.messageDetail.tooShort.

Tokens:
{value} - value entered by the user
{min} - the minimum allowed value

Usage:
The {value} has too few characters. Enter {min} or more characters, not less.

messageSummary Object <optional>
optional object literal of custom error summary message to be used.
Properties
Name Type Argument Description
tooLong string <optional>
the message to be used as the summary error message, when the length of the input value exceeds the maximum value set. When not present, the default message summary is the resource defined with the key oj-validator.length.messageSummary.tooLong.
tooShort string <optional>
the message to be used as the summary error message, when input value is less than the set minimum value. When not present, the default message summary is the resource defined with the key oj-validator.length.messageSummary.tooShort.
Source:

Methods

Init(options)

Initializes validator instance with the set options
Parameters:
Name Type Argument Description
options Object <optional>
Source:

validate(value) → {string}

Validates the length of vaue is greater than minimum and/or less than maximum.
Parameters:
Name Type Description
value string that is being validated
Source:
Throws:
when the length is out of range.
Type
Error
Returns:
original if validation was successful
Type
string