(schemaKeyRef, // key, ref or schema object
data // to be validated
)
| 3656 | return (this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : undefined); |
| 3657 | } |
| 3658 | validate(schemaKeyRef, // key, ref or schema object |
| 3659 | data // to be validated |
| 3660 | ) { |
| 3661 | let v; |
| 3662 | if (typeof schemaKeyRef == "string") { |
| 3663 | v = this.getSchema(schemaKeyRef); |
| 3664 | if (!v) |
| 3665 | throw new Error(`no schema with key or ref "${schemaKeyRef}"`); |
| 3666 | } |
| 3667 | else { |
| 3668 | v = this.compile(schemaKeyRef); |
| 3669 | } |
| 3670 | const valid = v(data); |
| 3671 | if (!("$async" in v)) |
| 3672 | this.errors = v.errors; |
| 3673 | return valid; |
| 3674 | } |
| 3675 | compile(schema, _meta) { |
| 3676 | const sch = this._addSchema(schema, _meta); |
| 3677 | return (sch.validate || this._compileSchemaEnv(sch)); |
no test coverage detected