-
Notifications
You must be signed in to change notification settings - Fork 11
/
exactly_one_of.go
25 lines (23 loc) · 974 Bytes
/
exactly_one_of.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package boolvalidator
import (
"github.com/hashicorp/terraform-plugin-framework-validators/internal/schemavalidator"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)
// ExactlyOneOf checks that of a set of path.Expression,
// including the attribute the validator is applied to,
// one and only one attribute has a value.
// It will also cause a validation error if none are specified.
//
// This implements the validation logic declaratively within the schema.
// Refer to [datasourcevalidator.ExactlyOneOf],
// [providervalidator.ExactlyOneOf], or [resourcevalidator.ExactlyOneOf]
// for declaring this type of validation outside the schema definition.
//
// Relative path.Expression will be resolved using the attribute being
// validated.
func ExactlyOneOf(expressions ...path.Expression) validator.Bool {
return schemavalidator.ExactlyOneOfValidator{
PathExpressions: expressions,
}
}