(ajv: Ajv)
| 24 | }) |
| 25 | |
| 26 | function addAsyncFormatsAndKeywords(ajv: Ajv) { |
| 27 | ajv.addFormat("date", /^\d\d\d\d-[0-1]\d-[0-3]\d$/) |
| 28 | |
| 29 | ajv.addFormat("english_word", { |
| 30 | async: true, |
| 31 | validate: checkWordOnServer, |
| 32 | }) |
| 33 | |
| 34 | ajv.addKeyword({ |
| 35 | keyword: "idExists", |
| 36 | async: true, |
| 37 | type: "number", |
| 38 | validate: checkIdExists, |
| 39 | errors: false, |
| 40 | }) |
| 41 | |
| 42 | ajv.addKeyword({ |
| 43 | keyword: "idExistsWithError", |
| 44 | async: true, |
| 45 | type: "number", |
| 46 | validate: checkIdExistsWithError, |
| 47 | errors: true, |
| 48 | }) |
| 49 | |
| 50 | ajv.addKeyword({ |
| 51 | keyword: "idExistsCompiled", |
| 52 | async: true, |
| 53 | type: "number", |
| 54 | compile: compileCheckIdExists, |
| 55 | }) |
| 56 | } |
| 57 | |
| 58 | function checkWordOnServer(str: string): Promise<boolean> { |
| 59 | return str === "tomorrow" |
nothing calls this directly
no test coverage detected
searching dependent graphs…