AndOperator

Monster.Constraints. AndOperator

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

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

Alternatively, you can also integrate this function individually.

<script type="module">
import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/constraints/andoperator.js';
new AndOperator();
</script>

Constructor

# new AndOperator()

Since:
  • 1.3.0
Example
import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/constraints/valid.js';
import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/constraints/invalid.js';
import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/constraints/andoperator.js';

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.

Parameters:
Name Type Description
value *
Returns:
Type
Promise