MCPcopy Index your code
hub / github.com/ampproject/amphtml / addCustomValidatorsToSchema

Function addCustomValidatorsToSchema

build-system/compile/json-schema/index.js:82–98  ·  view source on GitHub ↗

* @param {*} schema * @return {*}

(schema)

Source from the content-addressed store, hash-verified

80 * @return {*}
81 */
82function addCustomValidatorsToSchema(schema) {
83 if (typeof schema !== 'object') {
84 return schema;
85 }
86 if (Array.isArray(schema)) {
87 return schema.map(addCustomValidatorsToSchema);
88 }
89 for (const {fn, shouldUse} of customValidators) {
90 if (shouldUse(schema)) {
91 schema[`_${fn}`] = true;
92 }
93 }
94 for (const k in schema) {
95 schema[k] = addCustomValidatorsToSchema(schema[k]);
96 }
97 return schema;
98}
99
100/**
101 * Remaps `ajv-formats` in order to only use simple formats (true, string, RegExp).

Callers 1

ajvCompileFunction · 0.85

Calls 1

shouldUseFunction · 0.85

Tested by

no test coverage detected