class staticbo.system. ArgumentCheck
Source: system/
Methods
new ArgumentCheck([value])
Creates an argument check instance for the given value.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
value |
any type |
Yes |
The value to check. |
- Returns
-
bo.system.ArgumentCheck
The argument check instance.
Methods
staticasArray(type[, message][, ...messageParams]) → (Array of type or null)
forOptional: Checks if value is an array of a given type or null.
forMandatory: Checks if value is an array of a given type.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
type |
any type |
|
The type of the array items - a primitive type or a constructor. |
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be an array of TYPE values, or a single TYPE value or null.
-
Argument error: The argument must be an array of TYPE objects, or a single TYPE object or null.
-
Argument error: The argument must be an array of TYPE values, or a single TYPE value.
-
Argument error: The argument must be an array of TYPE objects, or a single TYPE object.
- Returns
-
(Array of type or null)
The checked value.
staticasBoolean([message][, ...messageParams]) → (boolean or null)
forOptional: Checks if value is a Boolean or null.
forMandatory: Checks if value is a Boolean.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be a Boolean value or null.
-
Argument error: The argument must be a Boolean value.
- Returns
-
(boolean or null)
The checked value.
staticasDefined([message][, ...messageParams]) → any type
for: Checks if value is not undefined.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be supplied.
- Returns
-
any type
The checked value.
staticasEnumMember(type[, defaultValue][, message][, ...messageParams]) → number
for: Checks if value is member of a given enumeration.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
type |
constructor |
|
The type of the enumeration. |
defaultValue |
number |
Yes |
The type of the enumeration. |
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: Type is not an enumeration type.
-
Argument error: The argument must be an enumeration type item.
- Returns
-
number
The checked value.
staticasFunction([message][, ...messageParams]) → (function() or null)
forOptional: Checks if value is a function or null.
forMandatory: Checks if value is a function.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be a function or null.
-
Argument error: The argument must be a function.
- Returns
-
(function() or null)
The checked value.
staticasInteger([message][, ...messageParams]) → (number or null)
forOptional: Checks if value is an integer or null.
forMandatory: Checks if value is an integer.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be an integer value or null.
-
Argument error: The argument must be an integer value.
- Returns
-
(number or null)
The checked value.
staticasModelType(model[, message][, ...messageParams]) → object
for: Checks if value is an instance of a given model type.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
model |
(constructor or Array of constructor) |
|
The model type that value must be an instance of. |
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be a model type.
- Returns
-
object
The checked value.
staticasNumber([message][, ...messageParams]) → (number or null)
forOptional: Checks if value is a number or null.
forMandatory: Checks if value is a number.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be a number value or null.
-
Argument error: The argument must be a number value.
- Returns
-
(number or null)
The checked value.
staticasObject([message][, ...messageParams]) → (object or null)
forOptional: Checks if value is an object or null.
forMandatory: Checks if value is an object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be an object or null.
-
Argument error: The argument must be an object.
- Returns
-
(object or null)
The checked value.
staticasString([message][, ...messageParams]) → (string or null)
for: Checks if value is a string.
forOptional: Checks if value is a string or null.
forMandatory: Checks if value is a non-empty string.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be a string value.
-
Argument error: The argument must be a string value or null.
-
Argument error: The argument must be a non-empty string.
- Returns
-
(string or null)
The checked value.
staticasType(type[, message][, ...messageParams]) → (object or null)
forOptional: Checks if value is a given type or null.
forMandatory: Checks if value is a given type.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
type |
(constructor or Array of constructor) |
|
The type that value must inherit. |
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument must be a TYPE object or null.
-
Argument error: The argument must be a TYPE object.
- Returns
-
(object or null)
The checked value.
staticfor([argumentName]) → bo.system.ArgumentCheck
Sets the name of the argument.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
argumentName |
string |
Yes |
The name of the argument. |
- Returns
-
bo.system.ArgumentCheck
The argument check instance.
staticforMandatory([argumentName]) → bo.system.ArgumentCheck
Sets the name of the mandatory argument.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
argumentName |
string |
Yes |
The name of the mandatory argument. |
- Returns
-
bo.system.ArgumentCheck
The argument check instance.
staticforOptional([argumentName]) → bo.system.ArgumentCheck
Sets the name of the optional argument.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
argumentName |
string |
Yes |
The name of the optional argument. |
- Returns
-
bo.system.ArgumentCheck
The argument check instance.
statichasValue([message][, ...messageParams]) → any type
for: Checks if value is not undefined and is not null.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the error. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The argument is required.
- Returns
-
any type
The checked value.