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

feat: When an unrelated error is seen with negated allow_value, give a hint #1570

Merged

Conversation

matsales28
Copy link
Member

To clean out some old PRs, I'm trying to push and merge some changes so we can close them. This is basically a copy of #1238, making the adjustments suggested on the code view. All the credit from this PR goes to @antifun.

I am quoting the PR owner.

In cases when an unrelated error is seen that makes allow_value fail, the validation message was using the erroneous text "but it was valid instead". This changes the validation message to indicate which attribute(s) actually failed validation.

Fixes #919 (kinda sorta).

Closes: #919 and #1238

In cases when an unrelated error is seen that makes `allow_value` fail,
the validation message was using the erroneous text "but it was valid
instead". This changes the validation message to indicate which
attribute(s) actually failed validation.
@matsales28 matsales28 self-assigned this Aug 18, 2023
@matsales28 matsales28 force-pushed the other-attribute-failure-messaging branch from 9e58506 to 6b6b227 Compare August 18, 2023 14:52
@matsales28 matsales28 force-pushed the other-attribute-failure-messaging branch from 6b6b227 to 7304b8f Compare August 18, 2023 14:54
This spec was failing because the polymorphic association was not optional,
that was causing it to have an error on the association and not in the attribute
`severity_type` that was being validated the inclusion.

Setting the association as optional fixed the issue.
Copy link
Collaborator

@vsppedro vsppedro left a comment

Choose a reason for hiding this comment

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

LGTM!

@matsales28 matsales28 merged commit f2db1f2 into thoughtbot:main Dec 8, 2023
9 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.

negative allow_value matcher incorrectly fails when validation message is custom but not passed to matcher
3 participants