Documentation
¶
Overview ¶
Package datasourcevalidator provides validators to express relationships between multiple attributes of a data source. For example, checking that multiple attributes are not configured at the same time.
These validators are implemented outside the schema, which may be easier to implement in provider code generation situations or suit provider code preferences differently than those in the schemavalidator package. Those validators start on a starting attribute, where relationships can be expressed as absolute paths to others or relative to the starting attribute.
Index ¶
- func All(validators ...datasource.ConfigValidator) datasource.ConfigValidator
- func Any(validators ...datasource.ConfigValidator) datasource.ConfigValidator
- func AnyWithAllWarnings(validators ...datasource.ConfigValidator) datasource.ConfigValidator
- func AtLeastOneOf(expressions ...path.Expression) datasource.ConfigValidator
- func Conflicting(expressions ...path.Expression) datasource.ConfigValidator
- func ExactlyOneOf(expressions ...path.Expression) datasource.ConfigValidator
- func RequiredTogether(expressions ...path.Expression) datasource.ConfigValidator
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶ added in v0.12.0
func All(validators ...datasource.ConfigValidator) datasource.ConfigValidator
All returns a validator which ensures that any configured attribute value validates against all the given validators.
Use of All is only necessary when used in conjunction with Any or AnyWithAllWarnings as the Validators field automatically applies a logical AND.
Example ¶
package main
import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
)
func main() {
// Used inside a datasource.DataSource type ConfigValidators method
_ = []datasource.ConfigValidator{
// The configuration must satisfy either All validator.
datasourcevalidator.Any(
datasourcevalidator.All( /* ... */ ),
datasourcevalidator.All( /* ... */ ),
),
}
}
Output: