import { parceable } from '../Schema' import SchemaItem from '../SchemaItem' export default class SchemaBoolean extends SchemaItem { /** * @param [trueValue='true'] the truhty value (default to `'true'`) * @param [falseValue='false'] the falthy value (default to `'false'`) */ @parceable() public parseString(trueValue = 'true', falseValue = 'false'): this { this.addPreProcess((it) => { if (typeof it !== 'string') { return it } if (it === trueValue) { return true } if (it === falseValue) { return false } return it }) return this } public override isOfType(input: unknown): input is boolean { return typeof input === 'boolean' } }