All files / dist/types boolean.js

82.5% Statements 33/40
62.06% Branches 18/29
81.81% Functions 9/11
86.84% Lines 33/38

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68  4x 4x 4x     4x   4x 4x   4x 4x 4x     4x 4x 4x 4x 4x 4x 4x             4x 4x   31x 31x 31x               4x 24x     24x 24x             4x 19x     19x 19x   4x   4x 4x 31x    
"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        Iif (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BooleanValidator = void 0;
var abstract_1 = require("./abstract");
var validators_1 = require("../utils/validators");
var constants_1 = require("../utils/constants");
var errors_1 = require("../utils/errors");
var boolean_1 = require("../messages/boolean");
/**
 * Boolean Validator Class
 *
 * @method equals
 * @method required
 */
var BooleanValidator = /** @class */ (function (_super) {
    __extends(BooleanValidator, _super);
    function BooleanValidator() {
        var _this = _super.call(this) || this;
        _this.validators.push({ validator: constants_1.TYPES.BOOLEAN, type: constants_1.BOOLEAN_VALIDATOR_TYPES.TYPE, message: (0, errors_1.boolean_type_error_message)("${{}}") });
        return _this;
    }
    /**
     * Equals Validator
     *
     * @param {Boolean} value
     * @param {String} message
     */
    BooleanValidator.prototype.equals = function (value, message) {
        Iif (message && !(0, validators_1.isString)(message)) {
            throw new Error((0, errors_1.string_type_error_message)("message"));
        }
        this.validators.push({ validator: constants_1.TYPES.BOOLEAN, type: constants_1.BOOLEAN_VALIDATOR_TYPES.EQUAL, value: value, message: message || (0, boolean_1.boolean_equal_error_message)() });
        return this;
    };
    /**
     * Reuired Validator
     *
     * @param {String} message
     */
    BooleanValidator.prototype.required = function (message) {
        Iif (message && !(0, validators_1.isString)(message)) {
            throw new Error((0, errors_1.string_type_error_message)("message"));
        }
        this.validators.push({ validator: constants_1.TYPES.BOOLEAN, type: constants_1.BOOLEAN_VALIDATOR_TYPES.REQUIRED, message: message || (0, boolean_1.boolean_required_error_message)() });
        return this;
    };
    return BooleanValidator;
}(abstract_1.default));
exports.BooleanValidator = BooleanValidator;
exports.default = (function () {
    return new BooleanValidator();
});