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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zeewell
Copy link

@zeewell zeewell commented Jul 9, 2024

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:

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

@go-playground/validator-maintainers

@zeewell zeewell requested a review from a team as a code owner July 9, 2024 03:56
@zeewell zeewell changed the title WIP: Add support for omitting empty and zero values in validation (including nil pointer and empty content of pointer) feat: Add support for omitting empty and zero values in validation (including nil pointer and empty content of pointer) Jul 9, 2024
@coveralls
Copy link

Coverage Status

coverage: 74.319% (+0.03%) from 74.291%
when pulling 835464d on zeewell:feature/omitzero
into a947377 on go-playground:master.

@zeewell
Copy link
Author

zeewell commented Jul 9, 2024

Fixes #249 #485 #698 #849

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.

2 participants