Skip to content

Commit

Permalink
Merge pull request #1442 from teq0/issue-1441
Browse files Browse the repository at this point in the history
Issue 1441
  • Loading branch information
epoberezkin authored Feb 13, 2021
2 parents 5b715aa + 6bd9c45 commit 6926312
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 @@ -742,7 +742,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 @@ -1099,6 +1099,10 @@ describe("User-defined keywords", () => {
ajv.addKeyword("colons:are-valid")
})

should.throw(() => {
ajv.addKeyword("single-'quote-not-valid")
}, /invalid name/)

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

0 comments on commit 6926312

Please sign in to comment.