MCPcopy Index your code
hub / github.com/fastify/fast-json-stringify / addSchema

Method addSchema

lib/validator.js:33–48  ·  view source on GitHub ↗
(schema, schemaName)

Source from the content-addressed store, hash-verified

31 }
32
33 addSchema (schema, schemaName) {
34 let schemaKey = schema.$id || schemaName
35 if (schema.$id !== undefined && schema.$id[0] === '#') {
36 schemaKey = schemaName + schema.$id // relative URI
37 }
38
39 if (
40 this.ajv.refs[schemaKey] === undefined &&
41 this.ajv.schemas[schemaKey] === undefined
42 ) {
43 const ajvSchema = clone(schema)
44 this.convertSchemaToAjvFormat(ajvSchema)
45 this.ajv.addSchema(ajvSchema, schemaKey)
46 this._ajvSchemas[schemaKey] = schema
47 }
48 }
49
50 validate (schemaRef, data) {
51 return this.ajv.validate(schemaRef, data)

Callers 4

buildFunction · 0.95
mergeLocationsFunction · 0.80
restoreFromStateMethod · 0.80
debug-mode.test.jsFile · 0.80

Calls 1

Tested by

no test coverage detected