Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially fixed dependency error messages #4417

Merged
merged 5 commits into from
Jan 9, 2025

Conversation

chibacchie
Copy link
Contributor

Reasons for making this change

Partially fixed issue where dependency errors do not show title or ui:title. This fix only applicable if we use an ajv-i18n localizer. Ref. #4402.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

…:title. This fix only applicable if we use an ajv-i18n localizer. Ref. rjsf-team#4402.
Copy link
Member

@heath-freenome heath-freenome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part this looks good. I've requested a few documentation comments as well as left you a question

Comment on lines +82 to +85
if ('missingProperty' in params) {
property = property ? `${property}.${params.missingProperty}` : params.missingProperty;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed since you are always adding missingProperty to rawPropertyNames above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this if clause as params.missingProperty may be undefined. If params.missingProperty is undefined, it is removed from rawPropertyNames by filter((item) => item).

Comment on lines +50 to +54
const uiSchemaPath = schemaPath
.replace(/\/properties\//g, '/')
.split('/')
.slice(1, -1)
.concat([currentProperty]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a comment that simply describes what these chained statements are accomplishing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I added a comment as follows:

To retrieve a title from UI schema, construct a path to UI schema from `schemaPath` and `currentProperty`.
For example, when `#/properties/A/properties/B/required` and `C` are given, they are converted into `['A', 'B', 'C']`.

}
});
if (error.params?.deps) {
error.params.deps = error.params.deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a comment that simply describes what these chained statements are accomplishing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment as follows:

As `error.params.deps` is the comma+space separated list of missing dependencies, enclose each dependency separately.
For example, `A, B` is converted into `'A', 'B'`.

Comment on lines +118 to +121
error.params.deps = error.params.deps
.split(', ')
.map((v: string) => v.slice(1, -1))
.join(', ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a comment that simply describes what these chained statements are accomplishing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment as follows:

Remove surrounding quotes from each missing dependency. For example, `'A', 'B'` is reverted to `A, B`.

@heath-freenome heath-freenome merged commit d211a7d into rjsf-team:main Jan 9, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants