1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/builtin/interopRequireDefault");
|
4 |
|
5 | exports.__esModule = true;
|
6 | exports.default = void 0;
|
7 |
|
8 | var _inherits = _interopRequireDefault(require("./util/inherits"));
|
9 |
|
10 | var _mixed = _interopRequireDefault(require("./mixed"));
|
11 |
|
12 | var _default = BooleanSchema;
|
13 | exports.default = _default;
|
14 |
|
15 | function BooleanSchema() {
|
16 | var _this = this;
|
17 |
|
18 | if (!(this instanceof BooleanSchema)) return new BooleanSchema();
|
19 |
|
20 | _mixed.default.call(this, {
|
21 | type: 'boolean'
|
22 | });
|
23 |
|
24 | this.withMutation(function () {
|
25 | _this.transform(function (value) {
|
26 | if (!this.isType(value)) {
|
27 | if (/^(true|1)$/i.test(value)) return true;
|
28 | if (/^(false|0)$/i.test(value)) return false;
|
29 | }
|
30 |
|
31 | return value;
|
32 | });
|
33 | });
|
34 | }
|
35 |
|
36 | (0, _inherits.default)(BooleanSchema, _mixed.default, {
|
37 | _typeCheck: function _typeCheck(v) {
|
38 | if (v instanceof Boolean) v = v.valueOf();
|
39 | return typeof v === 'boolean';
|
40 | }
|
41 | });
|
42 | module.exports = exports["default"]; |
\ | No newline at end of file |