Skip to content

Commit

Permalink
Merge pull request #1425 from teq0/issue-1421
Browse files Browse the repository at this point in the history
Issue 1421 - allow colons in keyword names
  • Loading branch information
epoberezkin committed Feb 2, 2021
2 parents 63486ce + 3727ae6 commit 3372277
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ function getLogger(logger?: Partial<Logger> | false): Logger {
throw new Error("logger must implement log, warn and error methods")
}

const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-]*$/i
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-:]*$/i

function checkKeyword(this: Ajv, keyword: string | string[], def?: KeywordDefinition): void {
const {RULES} = this
Expand Down
4 changes: 4 additions & 0 deletions spec/keyword.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,10 @@ describe("User-defined keywords", () => {
ajv.addKeyword("hyphens-are-valid")
})

should.not.throw(() => {
ajv.addKeyword("colons:are-valid")
})

should.throw(() => {
ajv.addKeyword("3-start-with-number-not-valid")
}, /invalid name/)
Expand Down

0 comments on commit 3372277

Please sign in to comment.