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

Function checkKeyword

lib/core.ts:826–836  ·  view source on GitHub ↗
(this: Ajv, keyword: string | string[], def?: KeywordDefinition)

Source from the content-addressed store, hash-verified

824const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i
825
826function checkKeyword(this: Ajv, keyword: string | string[], def?: KeywordDefinition): void {
827 const {RULES} = this
828 eachItem(keyword, (kwd) => {
829 if (RULES.keywords[kwd]) throw new Error(`Keyword ${kwd} is already defined`)
830 if (!KEYWORD_NAME.test(kwd)) throw new Error(`Keyword ${kwd} has invalid name`)
831 })
832 if (!def) return
833 if (def.$data && !("code" in def || "validate" in def)) {
834 throw new Error('$data keyword must have "code" or "validate" function')
835 }
836}
837
838function addRule(
839 this: Ajv,

Callers

nothing calls this directly

Calls 1

eachItemFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…