-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix: Better validation messages using schema/uiSchema title if it exists #3337
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
Fix: Better validation messages using schema/uiSchema title if it exists #3337
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, these have been sitting pending for days as I forgot to click submit, sorry
@dagda1 Would you please revert the |
Finally, once this is merged, we will release 5.0.0 |
oops, I think I might have a different version of npm than you. What version are you using. I have reverted the files. |
I'm using node 18 although node 16 also uses the same formats. I'm pushing a PR #3372 to bump the |
@heath-freenome I'm getting yellow lines in the coverage report because of the optional chaining around both message and parentSchema. e.g. message = message?.replace(currentProperty, uiSchemaTitle); and parentSchema?.[PROPERTIES_KEY]?.[currentProperty]?.title; |
@heath-freenome I am getting yellow lines in the coverage report around the optional chaining on I notice the existing code does this with message stack = message!; This tells the typescript compiler that And for |
If you look up the top of |
One last thing, don't forget to update the |
Co-authored-by: Heath C <[email protected]>
Co-authored-by: Heath C <[email protected]>
One required and one optional change and then we can merge it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... Sorry for being so picky, but a few more little things. I'd make them myself except I can't easily update the location of the import
Co-authored-by: Heath C <[email protected]>
Co-authored-by: Heath C <[email protected]>
Co-authored-by: Heath C <[email protected]>
Co-authored-by: Heath C <[email protected]>
@dagda1 Thanks for all your hard work on this PR and dealing with the feedback. I'm just awaiting the final move of the import in the test then I will merge |
the feedback was constructive so thank you for the good review |
…sts (rjsf-team#3337) * use title if available for validation errors * add title tests to validator-ajv8 validator tests * use scoped lodash/get * set verbose in createAjvInstance * use parentSchema for getting title * remove . in validator tests * rename local vars * remove duplicate local var * Update packages/validator-ajv8/test/validator.test.ts Co-authored-by: Heath C <[email protected]> * use params.missingProperty for currentProperty * check uiSchema for ui:title override in transformRJSFValidationErrors * revert package-lock.json files * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * add getUiOptions import * remove type arguments in call to getUiOptions * revert to leading period in default stack message * revert lock files * test for ajv8 ErrorObject optional fields * use array notation get * update CHANGELOG * Update CHANGELOG.md Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/package.json Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * move import * Update packages/validator-ajv8/test/validator.test.ts * Update CHANGELOG.md Co-authored-by: Heath C <[email protected]>
…sts (rjsf-team#3337) * use title if available for validation errors * add title tests to validator-ajv8 validator tests * use scoped lodash/get * set verbose in createAjvInstance * use parentSchema for getting title * remove . in validator tests * rename local vars * remove duplicate local var * Update packages/validator-ajv8/test/validator.test.ts Co-authored-by: Heath C <[email protected]> * use params.missingProperty for currentProperty * check uiSchema for ui:title override in transformRJSFValidationErrors * revert package-lock.json files * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * add getUiOptions import * remove type arguments in call to getUiOptions * revert to leading period in default stack message * revert lock files * test for ajv8 ErrorObject optional fields * use array notation get * update CHANGELOG * Update CHANGELOG.md Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/package.json Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * Update packages/validator-ajv8/src/validator.ts Co-authored-by: Heath C <[email protected]> * move import * Update packages/validator-ajv8/test/validator.test.ts * Update CHANGELOG.md Co-authored-by: Heath C <[email protected]>
Reasons for making this change
Fixes #3246 by reimplementing #2634
ErrorObject
message is enhanced by replacing the error message field with either theuiSchema
'sui:title
field if one exists or theparentSchema
title if one exists.Checklist
npm run test:update
to update snapshots, if needed.