Skip to content

Commit

Permalink
allow Code in KeywordErrorDefinition in addition to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Nov 22, 2020
1 parent 2ba056d commit 3bf88ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/compile/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ function errorObjectCode(cxt: KeywordErrorCxt, error: KeywordErrorDefinition): C
[E.keyword, keyword],
[N.dataPath, strConcat(N.dataPath, errorPath)],
[E.schemaPath, str`${errSchemaPath}/${keyword}`],
[E.params, params ? params(cxt) : _`{}`],
[E.params, typeof params == "function" ? params(cxt) : params || _`{}`],
]
if (propertyName) keyValues.push([E.propertyName, propertyName])
if (opts.messages !== false) {
const msg = typeof message == "string" ? message : message(cxt)
const msg = typeof message == "function" ? message(cxt) : message
keyValues.push([E.message, msg])
}
if (opts.verbose) {
Expand Down
4 changes: 2 additions & 2 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ export type AddedKeywordDefinition = KeywordDefinition & {
}

export interface KeywordErrorDefinition {
message: string | ((cxt: KeywordErrorCxt) => Code)
params?: (cxt: KeywordErrorCxt) => Code
message: string | Code | ((cxt: KeywordErrorCxt) => Code)
params?: Code | ((cxt: KeywordErrorCxt) => Code)
}

export type Vocabulary = (KeywordDefinition | string)[]
Expand Down

0 comments on commit 3bf88ee

Please # to comment.