MCPcopy Create free account
hub / github.com/ampproject/amphtml / getCustomValidatorKeywords

Function getCustomValidatorKeywords

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

* Creates a vocabulary keyword for each custom validator. * We name keywords by prefing the validator function name with an underscore: * { "_isIso4217CurrencyCode": true } * This format prevents them from clobbering the standard namespace * @param {Set } used * @return {import('ajv').

(used)

Source from the content-addressed store, hash-verified

65 * @return {import('ajv').KeywordDefinition[]}
66 */
67function getCustomValidatorKeywords(used) {
68 return customValidators.map(({error, fn}) => ({
69 keyword: `_${fn}`,
70 error,
71 code(ctx) {
72 used.add(fn);
73 ctx.pass(ajvCode`${new AjvName(fn)}(${ctx.data})`);
74 },
75 }));
76}
77
78/**
79 * @param {*} schema

Callers 1

ajvCompileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected