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

Fix formatting Validation Error for Map items #8333

Conversation

ebottacin
Copy link
Contributor

Description

In the validationError Array rendered there are string and maps.
The maps Item are not rendered correctly as you cam see in the image below

image

I've fixed the code to render properly these items

image

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

Copy link
Contributor

@glowcloud glowcloud left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, I can confirm that it works.
Please take a look at my comments.

errors.forEach( e => result.push(e))
errors
.map( e => {
if (e instanceof Map) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change this to if (Map.isMap(e)), to use a method from Immutable?

errors
.map( e => {
if (e instanceof Map) {
return `${e.get("propKey")} : ${e.get("error")}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the spacing before the colon ${e.get("propKey")}: ${e.get("error")}?

@glowcloud glowcloud self-assigned this Mar 7, 2024
@char0n char0n self-requested a review March 7, 2024 13:06
@char0n char0n self-assigned this Mar 7, 2024
return e
}
})
.forEach( e => result.push(e))
Copy link
Member

@char0n char0n Mar 7, 2024

Choose a reason for hiding this comment

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

Can we go for a little bit more concise way of writing this code?

errors
  .map((e) => (Map.isMap(e) ? `${e.get("propKey")} : ${e.get("error")}` : e))
  .forEach((e) => result.push(e))

Copy link
Member

@char0n char0n left a comment

Choose a reason for hiding this comment

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

Looks good, but we require either a unit test or e2e test to verify the code change. Would you be able to provide one?

@glowcloud
Copy link
Contributor

Refactored the code and added an e2e test in #9687.

Thanks for this again, your contribution will be properly attributed.

@glowcloud glowcloud closed this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants