Skip to content

Fix: Validator panics when 'nil' is used along with required if for slices and maps #1442

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

Merged
merged 4 commits into from
Jun 25, 2025

Conversation

JunaidIslam2105
Copy link
Contributor

Fixes

Added support to check for 'nil' values in case of maps and slices when used with required if. (Previously only lengths were being checked as a result using nil with required if would lead to a panic since the program tried to convert 'nil' to an integer)
Created a separate case for arrays to only check lengths since arrays cannot be nil in go.

Check #1437 for more details.

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

@JunaidIslam2105 JunaidIslam2105 requested a review from a team as a code owner June 18, 2025 06:21
@coveralls
Copy link

coveralls commented Jun 18, 2025

Coverage Status

coverage: 73.686% (+0.008%) from 73.678%
when pulling f20d93d on JunaidIslam2105:validator-panic-bug
into 0e3e2f9 on go-playground:master.

@JunaidIslam2105
Copy link
Contributor Author

@nodivbyzero kindly take a look and let me know if I need to change anything else

@JunaidIslam2105
Copy link
Contributor Author

@nodivbyzero, if everything looks good, can we merge?

@nodivbyzero nodivbyzero merged commit ec374ef into go-playground:master Jun 25, 2025
12 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.

3 participants