1 | import isSchema from './util/isSchema';
|
2 |
|
3 | var Lazy = function () {
|
4 | function Lazy(mapFn) {
|
5 | this._resolve = function (value, options) {
|
6 | var schema = mapFn(value, options);
|
7 | if (!isSchema(schema)) throw new TypeError('lazy() functions must return a valid schema');
|
8 | return schema.resolve(options);
|
9 | };
|
10 | }
|
11 |
|
12 | var _proto = Lazy.prototype;
|
13 |
|
14 | _proto.resolve = function resolve(options) {
|
15 | return this._resolve(options.value, options);
|
16 | };
|
17 |
|
18 | _proto.cast = function cast(value, options) {
|
19 | return this._resolve(value, options).cast(value, options);
|
20 | };
|
21 |
|
22 | _proto.validate = function validate(value, options, maybeCb) {
|
23 | return this._resolve(value, options).validate(value, options, maybeCb);
|
24 | };
|
25 |
|
26 | _proto.validateSync = function validateSync(value, options) {
|
27 | return this._resolve(value, options).validateSync(value, options);
|
28 | };
|
29 |
|
30 | _proto.validateAt = function validateAt(path, value, options) {
|
31 | return this._resolve(value, options).validateAt(path, value, options);
|
32 | };
|
33 |
|
34 | _proto.validateSyncAt = function validateSyncAt(path, value, options) {
|
35 | return this._resolve(value, options).validateSyncAt(path, value, options);
|
36 | };
|
37 |
|
38 | return Lazy;
|
39 | }();
|
40 |
|
41 | Lazy.prototype.__isYupSchema__ = true;
|
42 | export default Lazy; |
\ | No newline at end of file |