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(ui): Add helper function to cast string to array before yup validation #86

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

deadlycoconuts
Copy link
Contributor

What this PR does / why we need it:
It seems like after updating yup/elastic UI packages, array values in the EuiTextArea are expressed as a JSON literal, e.g. "[\"new\"]" and these values no longer get automatically parsed into a JSON array at the yup validation stage. As a result, all the .array() validations that were performed no longer work and fail (because they report a string being present instead). The screenshot attached shows how the validation reports an error even though nothing is wrong with the input in the text fields.

An additional step is thus introduced to manually parse the literal input into a JSON array (failing the validation check if it isn't), and to validate the parsed array with respect to the original schema.

Screenshot 2024-08-12 at 13 41 11

Which issue(s) this PR fixes:

Fixes #

@deadlycoconuts deadlycoconuts added the bug Something isn't working label Aug 12, 2024
@deadlycoconuts deadlycoconuts self-assigned this Aug 12, 2024
Copy link

@bthari bthari left a comment

Choose a reason for hiding this comment

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

Thank you for this fix! LGTM 🚀

@deadlycoconuts
Copy link
Contributor Author

Thanks for the quick review! I'll merge this soon!

@deadlycoconuts deadlycoconuts merged commit d328d9e into caraml-dev:main Aug 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants