Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 3x | import isSchema from './util/isSchema'
class Lazy {
constructor(mapFn) {
this._resolve = (value, options) => {
let schema = mapFn(value, options)
if (!isSchema(schema))
throw new TypeError('lazy() functions must return a valid schema')
return schema.resolve(options)
}
}
resolve(options) {
return this._resolve(options.value, options)
}
cast(value, options) {
return this._resolve(value, options).cast(value, options)
}
validate(value, options, maybeCb) {
return this._resolve(value, options).validate(value, options, maybeCb)
}
validateSync(value, options) {
return this._resolve(value, options).validateSync(value, options)
}
validateAt(path, value, options) {
return this._resolve(value, options).validateAt(path, value, options)
}
validateSyncAt(path, value, options) {
return this._resolve(value, options).validateSyncAt(path, value, options)
}
}
Lazy.prototype.__isYupSchema__ = true
export default Lazy
|