MCPcopy
hub / github.com/ajv-validator/ajv / if

Method if

lib/compile/codegen/index.ts:566–577  ·  view source on GitHub ↗
(condition: Code | boolean, thenBody?: Block, elseBody?: Block)

Source from the content-addressed store, hash-verified

564
565 // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
566 if(condition: Code | boolean, thenBody?: Block, elseBody?: Block): CodeGen {
567 this._blockNode(new If(condition))
568
569 if (thenBody && elseBody) {
570 this.code(thenBody).else().code(elseBody).endIf()
571 } else if (thenBody) {
572 this.code(thenBody).endIf()
573 } else if (elseBody) {
574 throw new Error('CodeGen: "else" body without "then" body')
575 }
576 return this
577 }
578
579 // `else if` clause - invalid without `if` or after `else` clauses
580 elseIf(condition: Code | boolean): CodeGen {

Callers 15

checkReportMissingPropFunction · 0.80
validateItemsFunction · 0.80
validateUnionFunction · 0.80
callAsyncRefFunction · 0.80
validatePropertyDepsFunction · 0.80
validateSchemaDepsFunction · 0.80
codeFunction · 0.80
codeFunction · 0.80
validatePropertiesFunction · 0.80
validateTupleFunction · 0.80
validateAdditionalItemsFunction · 0.80

Calls 4

_blockNodeMethod · 0.95
codeMethod · 0.95
endIfMethod · 0.80
elseMethod · 0.80

Tested by 1

codeFunction · 0.64