Skip to content

Commit c6d7888

Browse files
committed
simplified use of custom keywordMatcher
1 parent 318743a commit c6d7888

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/error-filtering.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,7 @@ export const duplicateIdentifierMatcher = (index: number) => {
6161
}
6262

6363
export const duplicateKeywordMatcher = (index: number) => {
64-
return (error: ErrorObject) => {
65-
if (error.instancePath !== '/keywords') {
66-
return false
67-
}
68-
if (error.schemaPath !== '#/properties/keywords/uniqueItems') {
69-
return false
70-
}
71-
if (error.params.i !== index && error.params.j !== index) {
72-
return false
73-
}
74-
return true
75-
}
64+
return (error: ErrorObject) => error.params.i === index || error.params.j === index
7665
}
7766

7867
export const byError = (errors: ErrorObject[], matcher: Comparator = defaultMatcher) => {
@@ -125,7 +114,10 @@ export const duplicateIdentifierQueries: ErrorQuery[] = [{
125114
}]
126115

127116
export const duplicateKeywordQueries: ErrorQuery[] = [{
128-
find: {},
117+
find: {
118+
instancePath: '/keywords',
119+
schemaPath: '#/properties/keywords/uniqueItems'
120+
},
129121
replace: {
130122
message: 'This keyword is a duplicate.'
131123
}

0 commit comments

Comments
 (0)