validator icon indicating copy to clipboard operation
validator copied to clipboard

feat: Add support for omitting empty and zero values in validation (including nil pointer and empty content of pointer)

Open zeewell opened this issue 1 year ago • 2 comments

Fixes Or Enhances

Add the omitzero Tag:

  • It allows you to ignore the subsequent validations if the value of a field is empty
  • If the field is a pointer and the pointer is nil, ignore the subsequent validations
  • If the field is a pointer and the pointer is not nil, but the content value of the pointer is zero, the subsequent validations will be ignored

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

zeewell avatar Jul 09 '24 03:07 zeewell

Coverage Status

coverage: 74.347% (+0.03%) from 74.318% when pulling 68a05949d0621e695618b4b32824506598d2275b on zeewell:feature/omitzero into 6c3307e6c64040ebc0efffe9366927c68146ffba on go-playground:master.

coveralls avatar Jul 09 '24 03:07 coveralls

Fixes #249 #485 #698 #849

zeewell avatar Jul 09 '24 04:07 zeewell

Waiting for this to be merged

orihomie avatar Jan 08 '25 11:01 orihomie

@deankarn This PR's merge has been blocked, can you help take a look at the issue?

zeewell avatar Jan 14 '25 03:01 zeewell

@deankarn Do you know when this might be merged?

chrislentz avatar Feb 13 '25 03:02 chrislentz

Sorry @chrislentz been getting some more people to help maintain this package as my time is super limited.

No reason I can see not to merge though.

deankarn avatar Feb 15 '25 16:02 deankarn

Sorry @chrislentz been getting some more people to help maintain this package as my time is super limited.

No reason I can see not to merge though.

@deankarn If possible, I would like to become a maintainer of this package.

zeewell avatar Feb 16 '25 03:02 zeewell