Skip to content

Commit 82eac95

Browse files
committed
Add comments.
1 parent caa59ca commit 82eac95

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

packages/validator-ajv8/src/processRawValidationErrors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export function transformRJSFValidationErrors<
4747
const path = property ? `${property}.${currentProperty}` : currentProperty;
4848
let uiSchemaTitle = getUiOptions(get(uiSchema, `${path.replace(/^\./, '')}`)).title;
4949
if (uiSchemaTitle === undefined) {
50+
// To retrieve a title from UI schema, construct a path to UI schema from `schemaPath` and `currentProperty`.
51+
// For example, when `#/properties/A/properties/B/required` and `C` are given, they are converted into `['A', 'B', 'C']`.
5052
const uiSchemaPath = schemaPath
5153
.replace(/\/properties\//g, '/')
5254
.split('/')

packages/validator-ajv8/src/validator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSch
100100
}
101101
});
102102
if (error.params?.deps) {
103+
// As `error.params.deps` is the comma+space separated list of missing dependencies, enclose each dependency separately.
104+
// For example, `A, B` is converted into `'A', 'B'`.
103105
error.params.deps = error.params.deps
104106
.split(', ')
105107
.map((v: string) => `'${v}'`)
@@ -115,6 +117,7 @@ export default class AJV8Validator<T = any, S extends StrictRJSFSchema = RJSFSch
115117
}
116118
});
117119
if (error.params?.deps) {
120+
// Remove surrounding quotes from each missing dependency. For example, `'A', 'B'` is reverted to `A, B`.
118121
error.params.deps = error.params.deps
119122
.split(', ')
120123
.map((v: string) => v.slice(1, -1))

0 commit comments

Comments
 (0)