MCPcopy Create free account
hub / github.com/fastify/fastify / setValidatorCompiler

Method setValidatorCompiler

lib/schema-controller.js:75–95  ·  view source on GitHub ↗
(validatorCompiler)

Source from the content-addressed store, hash-verified

73 }
74
75 setValidatorCompiler (validatorCompiler) {
76 // Set up as if the fixed validator compiler had been provided
77 // by a custom 'options.compilersFactory.buildValidator' that
78 // always returns the same compiler object. This is required because:
79 //
80 // - setValidatorCompiler must immediately install a compiler to preserve
81 // legacy behavior
82 // - setupValidator will recreate compilers from builders in some
83 // circumstances, so we have to install this adapter to make it
84 // behave the same if the legacy API is used
85 //
86 // The cloning of the compilersFactory object is necessary because
87 // we are aliasing the parent compilersFactory if none was provided
88 // to us (see constructor.)
89 this.compilersFactory = Object.assign(
90 {},
91 this.compilersFactory,
92 { buildValidator: () => validatorCompiler })
93 this.validatorCompiler = validatorCompiler
94 this.isCustomValidatorCompiler = true
95 }
96
97 setSerializerCompiler (serializerCompiler) {
98 // Set up as if the fixed serializer compiler had been provided

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected