Class: ArgumentCheck

bo.system. ArgumentCheck

new ArgumentCheck(value) → {bo.system.ArgumentCheck}

Creates an argument check instance for the given value.

Parameters:
Name Type Argument Description
value * <optional>

The value to check.

Returns:

The argument check instance.

Type
bo.system.ArgumentCheck

Methods

<static> asArray(type, message, messageParams) → {Array.<type>|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 Argument Description
type *

The type of the array items - a primitive type or a constructor.

message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

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:

The checked value.

Type
Array.<type> | null

<static> asBoolean(message, messageParams) → {boolean|null}

forOptional: Checks if value is a Boolean or null.
forMandatory: Checks if value is a Boolean.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
boolean | null

<static> asDefined(message, messageParams) → {*}

for: Checks if value is not undefined.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Argument error: The argument must be supplied.
Returns:

The checked value.

Type
*

<static> asEnumMember(type, defaultValue, message, messageParams) → {number}

for: Checks if value is member of a given enumeration.

Parameters:
Name Type Argument Description
type constructor

The type of the enumeration.

defaultValue number <optional>

The type of the enumeration.

message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
number

<static> asFunction(message, messageParams) → {function|null}

forOptional: Checks if value is a function or null.
forMandatory: Checks if value is a function.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
function | null

<static> asInteger(message, messageParams) → {number|null}

forOptional: Checks if value is an integer or null.
forMandatory: Checks if value is an integer.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
number | null

<static> asModelType(model, message, messageParams) → {object}

for: Checks if value is an instance of a given model type.

Parameters:
Name Type Argument Description
model constructor | Array.<constructor>

The model type that value must be an instance of.

message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Argument error: The argument must be a model type.
Returns:

The checked value.

Type
object

<static> asNumber(message, messageParams) → {number|null}

forOptional: Checks if value is a number or null.
forMandatory: Checks if value is a number.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
number | null

<static> asObject(message, messageParams) → {object|null}

forOptional: Checks if value is an object or null.
forMandatory: Checks if value is an object.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
object | null

<static> asString(message, messageParams) → {string|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 Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
string | null

<static> asType(type, message, messageParams) → {object|null}

forOptional: Checks if value is a given type or null.
forMandatory: Checks if value is a given type.

Parameters:
Name Type Argument Description
type constructor | Array.<constructor>

The type that value must inherit.

message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Returns:

The checked value.

Type
object | null

<static> for(argumentName) → {bo.system.ArgumentCheck}

Sets the name of the argument.

Parameters:
Name Type Argument Description
argumentName string <optional>

The name of the argument.

Returns:

The argument check instance.

Type
bo.system.ArgumentCheck

<static> forMandatory(argumentName) → {bo.system.ArgumentCheck}

Sets the name of the mandatory argument.

Parameters:
Name Type Argument Description
argumentName string <optional>

The name of the mandatory argument.

Returns:

The argument check instance.

Type
bo.system.ArgumentCheck

<static> forOptional(argumentName) → {bo.system.ArgumentCheck}

Sets the name of the optional argument.

Parameters:
Name Type Argument Description
argumentName string <optional>

The name of the optional argument.

Returns:

The argument check instance.

Type
bo.system.ArgumentCheck

<static> hasValue(message, messageParams) → {*}

for: Checks if value is not undefined and is not null.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the error.

messageParams * <optional>
<repeatable>

Optional interpolation parameters of the message.

Throws:
Argument error: The argument is required.
Returns:

The checked value.

Type
*
If you find bugs or have feature requests, please let us know.

JavaScript business objects ♦ Copyright © 2014-2016 Logikum, Ltd.
Documentation generated by JSDoc 3.2.2 on 2015. December 31. using the DocStrap template.