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

Custom array validation using path will only show "1 error" when hovering entries instead of the error itself #8869

Open
fvieira opened this issue Mar 8, 2025 · 0 comments

Comments

@fvieira
Copy link

fvieira commented Mar 8, 2025

Describe the bug

When making a custom array validation and using path to make the errors appear on the right array entries, it only shows "1 error" on hover, while it would be way more useful to show the error itself (and which I believe used to be the behavior in the past, not sure).

To Reproduce

Add the validation below to any non-empty array:

validation: Rule =>
  Rule.custom(items =>
    items && items.length > 0
      ? items.map(item => ({
          message: 'My error message',
          path: [
            {
              _key: (item as KeyedObject)._key,
            },
          ],
        }))
      : true,
  ),

Then go to the studio and hover the error icon in the array entries.

Expected behavior

At least when there is only one error, it should show it on hover without forcing me to go to the global validations sidebar, maybe even if there were more than one, as I'm sure they would fit.

Screenshots

Image

Which versions of Sanity are you using?

@sanity/cli (global) 3.73.0 (latest: 3.78.1)
@sanity/cli 3.73.0 (latest: 3.78.1)
@sanity/color 2.2.5 (latest: 3.0.6)
@sanity/dashboard 3.1.6 (latest: 4.1.2)
@sanity/icons 2.11.8 (latest: 3.7.0)
@sanity/orderable-document-list 1.2.3 (up to date)
@sanity/schema 3.73.0 (latest: 3.78.1)
@sanity/types 3.73.0 (latest: 3.78.1)
@sanity/ui 2.14.0 (latest: 2.15.2)
@sanity/vision 3.73.0 (latest: 3.78.1)
sanity 3.73.0 (latest: 3.78.1)

I also tested after updating to the latest, same thing happened.

What operating system are you using?

Ubuntu

Which versions of Node.js / npm are you running?

10.1.0
v20.9.0

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

No branches or pull requests

1 participant