'use strict';
/**
* @author schukai GmbH
*/
import {Monster, AbstractConstraint} from "./abstract.js";
import {AbstractOperator} from "./abstractoperator.js";
/**
* 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.5.0/dist/modules/constraints/andoperator.js';
* new Monster.Constraint.AndOperator(new Monster.Constraint.Valid(), new Monster.Constraint.Valid()).then(()=>console.log(true)).catch(()=>console.log(false));
* </script>
* ```
*
* Alternatively, you can also integrate this function individually.
*
* ```
* <script type="module">
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/constraint/valid.js';
* import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/constraints/andoperator.js';
* new AndOperator(new Valid(), new Valid()).then(()=>console.log(true)).catch(()=>console.log(false));
* </script>
* ```
*
* @since 1.3.0
* @copyright schukai GmbH
* @memberOf Monster/Constraints
*/
class AndOperator extends AbstractOperator {
/**
* this method return a promise containing the result of the check.
*
* @param {*} value
* @returns {Promise}
*/
isValid(value) {
return Promise.all([this.operantA.isValid(value), this.operantB.isValid(value)]);
}
}
Monster.assignToNamespace('Monster.Constraints', AndOperator);
export {Monster, AndOperator}