import inherits from './util/inherits'; import MixedSchema from './mixed'; export default BooleanSchema; function BooleanSchema() { var _this = this; if (!(this instanceof BooleanSchema)) return new BooleanSchema(); MixedSchema.call(this, { type: 'boolean' }); this.withMutation(function () { _this.transform(function (value) { if (!this.isType(value)) { if (/^(true|1)$/i.test(value)) return true; if (/^(false|0)$/i.test(value)) return false; } return value; }); }); } inherits(BooleanSchema, MixedSchema, { _typeCheck: function _typeCheck(v) { if (v instanceof Boolean) v = v.valueOf(); return typeof v === 'boolean'; } });