* 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)
| 65 | * @return {import('ajv').KeywordDefinition[]} |
| 66 | */ |
| 67 | function 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 |