orm/src/schema/types/Boolean.js

/**
 * @module flitter-orm/src/schema/types/Boolean
 */

const Type = require('../Type')

/**
 * Schema type representing a boolean value.
 * @extends {module:flitter-orm/src/schema/Type~Type}
 */
class BooleanType extends Type {
    /**
     * Determines whether a value can be cast to boolean.
     * @param {*} value
     * @returns {boolean} - always true
     */
    static validate(value) {
        return true
    }

    /**
     * Casts the specified value to boolean.
     * @param {*} value
     * @returns {boolean}
     */
    static cast(value) {
        return Boolean(value)
    }
}

module.exports = exports = BooleanType