Monster.Constraints. OrOperator

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 OrOperator is used to link several constraints. The constraint is fulfilled if one of the constraints is fulfilled.

Constructor

new OrOperator()

A or operator

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 {OrOperator} from '@schukai/monster/source/constraints/oroperator.mjs';

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

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

Members

(static) instanceSymbol

This method is called by the instanceof operator.

This method is called by the instanceof operator.

Since
  • 2.1.0

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