UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/builtin/interopRequireDefault");
4
5exports.__esModule = true;
6exports.default = void 0;
7
8var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/builtin/objectWithoutPropertiesLoose"));
9
10var _isSchema = _interopRequireDefault(require("./util/isSchema"));
11
12var Lazy =
13/*#__PURE__*/
14function () {
15 function Lazy(mapFn) {
16 this._resolve = function () {
17 var schema = mapFn.apply(void 0, arguments);
18 if (!(0, _isSchema.default)(schema)) throw new TypeError('lazy() functions must return a valid schema');
19 return schema;
20 };
21 }
22
23 var _proto = Lazy.prototype;
24
25 _proto.resolve = function resolve(_ref) {
26 var value = _ref.value,
27 rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["value"]);
28 return this._resolve(value, rest);
29 };
30
31 _proto.cast = function cast(value, options) {
32 return this._resolve(value, options).cast(value, options);
33 };
34
35 _proto.validate = function validate(value, options) {
36 return this._resolve(value, options).validate(value, options);
37 };
38
39 return Lazy;
40}();
41
42Lazy.prototype.__isYupSchema__ = true;
43var _default = Lazy;
44exports.default = _default;
45module.exports = exports["default"];
\No newline at end of file