IsArray

Monster.Constraints. IsArray

Constraints are used to define conditions that must be met by the value of a variable.

The uniform API of the constraints allows chains to be formed.

You can call the method via the monster namespace new Monster.Constraint.IsObject().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
new Monster.Constraint.IsArray()
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/constraints/isarray.js';
console.log(new IsArray())
</script>

Constructor

# new IsArray()

A constraint to check if a value is an array

Since:
  • 1.3.0
Example
import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/constraints/isarray.js';

new IsArray()
.isValid([])
.then(()=>console.log(true));
// ↦ true

new IsArray()
.isValid(99)
.catch(e=>console.log(e));
// ↦ 99

Methods

# isValid(value) → {Promise}

this method return a promise containing the result of the check.

Parameters:
Name Type Description
value *
Returns:
Type
Promise