Monster.Constraints. AndOperator

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.

The AndOperator is used to link several constraints. The constraint is fulfilled if all constraints of the operators are fulfilled.

Constructor

new AndOperator()

A and operator constraint

Since
  • 1.3.0
License
  • AGPLv3
Example
import {Valid} from '@schukai/monster/source/constraints/valid.mjs';
import {Invalid} from '@schukai/monster/source/constraints/invalid.mjs';
import {AndOperator} from '@schukai/monster/source/constraints/andoperator.mjs';

new AndOperator(
    new Valid(), new Valid()).isValid()
    .then(() => console.log(true))
    .catch(() => console.log(false));
// ↦ true

new AndOperator(
    new Invalid(), new Valid()).isValid()
    .then(() => console.log(true))
    .catch(() => console.log(false));
// ↦ false


Methods

isValid(value) → {Promise}

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

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

Parameters:
NameTypeDescription
value*
Returns:
Type: 
Promise