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

fix: remove "required" binding from Deployable bool field #341

Merged
merged 2 commits into from Jul 20, 2023

Conversation

radnov
Copy link
Contributor

@radnov radnov commented Jul 19, 2023

Turns out that if the Deployable bool field is false, the validation from the "required" tag will fail

Error #01: Key: 'CreateGroupRequest.Deployable' Error:Field validation for 'Deployable' failed on the 'required' tag

as it's considered the zero-value for bools. In our case both true and false are valid, so there's no need to use the "required" tag.

I've also handled the duplicated key error when creating a group, but I'm not sure how to distinguish between duplicated Hostname and Name. Any ideas?

If the Deployable bool field is `false`, the validation from the "required" tag will fail,
as it's considered the zero-value for bools. In our case both `true` and `false`
are valid, so there's no need to use the "required" tag.

go-playground/validator#713
@radnov radnov requested review from tonsV2 and teleivo July 19, 2023 09:55
pkg/group/repository.go Show resolved Hide resolved
Copy link
Contributor

@teleivo teleivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it was not for #342 I would request a test 😋 so you are off the hook 😁

pkg/group/repository.go Show resolved Hide resolved
@radnov radnov merged commit 326d1d6 into master Jul 20, 2023
3 checks passed
@radnov radnov deleted the fix/create-group branch July 20, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants