validator icon indicating copy to clipboard operation
validator copied to clipboard

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

Open JunaidIslam2105 opened this issue 6 months ago • 2 comments

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:

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

@go-playground/validator-maintainers

JunaidIslam2105 avatar Jun 18 '25 06:06 JunaidIslam2105

Coverage Status

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

coveralls avatar Jun 18 '25 06:06 coveralls

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

JunaidIslam2105 avatar Jun 18 '25 06:06 JunaidIslam2105

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

JunaidIslam2105 avatar Jun 21 '25 03:06 JunaidIslam2105