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

resource virtual network dhcp_service_enabled validation isn't quite right #86

Open
chrismarget-j opened this issue May 18, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@chrismarget-j
Copy link
Collaborator

chrismarget-j commented May 18, 2023

When dhcp_service_enabled is true, one or both of these must also be true:

  • ipv4_connectivity_enabled
  • ipv6_connectivity_enabled

This rule was attempted with the following validation:

			Validators: []validator.Bool{
				apstravalidator.WhenValueIsBool(types.BoolValue(true),
					apstravalidator.AlsoRequiresNOf(1,
						path.MatchRelative().AtParent().AtName("ipv4_connectivity_enabled"),
						path.MatchRelative().AtParent().AtName("ipv6_connectivity_enabled"),
					),
				),
			},

The problem is that apstravalidator.AlsoRequiresNOf only requires that the paths be configured (not null), rather than that they be configured with any particular value.

Setting both to false will pass validation while dhcp_service_enabled is true.

Perhaps we need a NOfValidators(n int, ...v validator) validator which calls the enumerated validators and counts how many of them run without error?

In that case we'd pass it the valueAtMustBeValidator{}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants