Skip to content

Conversation

Madoxen
Copy link

@Madoxen Madoxen commented Apr 1, 2025

As in #684

Running validator on a map or struct results in such error output:

=== RUN   TestStructValidator/Test_map
    validate_test.go:205: unexpected error: [3:8] Key: 'Map' Error:Field validation for 'Map' failed on the 'eq' tag
           2 | map:
        >  3 |   hello: hello
                      ^
           4 |   hello2: hello

The error arrow positioning is unexpected as it's pointing to inner map value instead of pointing to the token defining the map. This can be confusing for the consumers of an error.

Expected output would be:

=== RUN   TestStructValidator/Test_Required_map
    validate_test.go:205: unexpected error: [1:4] Key: 'Map' Error:Field validation for 'Map' failed on the 'eq' tag
           > 2 | map:
                     ^
           3 |   hello: hello
           4 |   hello2: hello

Fixes: #684

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.88%. Comparing base (ba0598a) to head (7932914).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #685   +/-   ##
=======================================
  Coverage   77.87%   77.88%           
=======================================
  Files          22       22           
  Lines        7960     7963    +3     
=======================================
+ Hits         6199     6202    +3     
  Misses       1348     1348           
  Partials      413      413           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@goccy
Copy link
Owner

goccy commented May 5, 2025

@Madoxen Thank you for your contribution !! I've fixed this problem myself with this PR to add the null checking and more test cases.

@goccy goccy closed this May 5, 2025
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.

Incorrect source annotation for validator
3 participants