"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeIsBooleanFixValue = exports.TypeIsBooleanToSequelize = exports.TypeIsBooleanToSwagger = void 0;
const sequelize_1 = require("sequelize");
const toSequelizeGenerator_1 = require("./generators/toSequelizeGenerator");
const toSwaggerGenerator_1 = require("./generators/toSwaggerGenerator");
const typeGenerator_1 = require("./generators/typeGenerator");
exports.TypeIsBooleanToSwagger = (0, toSwaggerGenerator_1.toSwaggerGenerator)((options) => ({
    type: 'boolean',
    description: options === null || options === void 0 ? void 0 : options.comment,
}));
exports.TypeIsBooleanToSequelize = (0, toSequelizeGenerator_1.toSequelizeGenerator)((options) => (Object.assign(Object.assign({}, options), { type: sequelize_1.DataTypes.BOOLEAN, comment: options === null || options === void 0 ? void 0 : options.comment })));
const TypeIsBooleanFixValue = (o) => {
    if (o === undefined || o === null)
        return o;
    const v = String(o) === 'true' ? true : String(o) === 'false' ? false : !!o;
    return Boolean(v);
};
exports.TypeIsBooleanFixValue = TypeIsBooleanFixValue;
const TypeIsBoolean = (0, typeGenerator_1.typeGenerator)((options) => ({
    __name: 'boolean',
    toSwagger: () => (0, exports.TypeIsBooleanToSwagger)(options),
    toSequelize: () => (0, exports.TypeIsBooleanToSequelize)(options),
    fixValue: exports.TypeIsBooleanFixValue,
}));
exports.default = TypeIsBoolean;
//# sourceMappingURL=boolean.js.map