(n: ValueScopeName)
| 66 | return s.evaluated ? _`${code}${s.validateName}.evaluated = ${s.evaluated};${_n}` : code |
| 67 | |
| 68 | function refValidateCode(n: ValueScopeName): Code | undefined { |
| 69 | const vRef = n.value?.ref |
| 70 | if (n.prefix === "validate" && typeof vRef == "function") { |
| 71 | const v = vRef as AnyValidateFunction |
| 72 | return validateCode(usedValues, v.source) |
| 73 | } else if ((n.prefix === "root" || n.prefix === "wrapper") && typeof vRef == "object") { |
| 74 | const {validate, validateName} = vRef as SchemaEnv |
| 75 | if (!validateName) throw new Error("ajv internal error") |
| 76 | const def = ajv.opts.code.es5 ? varKinds.var : varKinds.const |
| 77 | const wrapper = _`${def} ${n} = {validate: ${validateName}};` |
| 78 | if (usedState(validateName) === UsedValueState.Started) return wrapper |
| 79 | const vCode = validateCode(usedValues, validate?.source) |
| 80 | return _`${wrapper}${_n}${vCode}` |
| 81 | } |
| 82 | return undefined |
| 83 | } |
| 84 | |
| 85 | function usedState(name: ValueScopeName): UsedValueState | undefined { |
| 86 | return usedValues[name.prefix]?.get(name) |
nothing calls this directly
no test coverage detected
searching dependent graphs…