constraints/valid.js

'use strict';

/**
 * @author schukai GmbH
 */

import {Monster, AbstractConstraint} from "./abstract.js";

/**
 * the valid constraint allows an always valid query to be performed. this contraint is mainly intended for testing.
 *
 * you can call the method via the monster namespace `new Monster.Constraint.Valid()`.
 *
 * ```
 * <script type="module">
 * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.5.0/dist/modules/constraints/valid.js';
 * new Monster.Constraint.Valid().then(()=>console.log(true));
 * </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/constraints/valid.js';
 * new Valid().then(()=>console.log(true));
 * </script>
 * ```
 *
 * @since 1.3.0
 * @copyright schukai GmbH
 * @memberOf Monster/Constraints
 */
class Valid extends AbstractConstraint {

    /**
     * this method return a promise containing the result of the check.
     *
     * @param {*} value
     * @returns {Promise}
     */
    isValid(value) {
        return Promise.resolve(value);
    }

}

Monster.assignToNamespace('Monster.Constraints', Valid);
export {Monster, Valid}