datasourcevalidator

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2025 License: MPL-2.0 Imports: 6 Imported by: 16

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.12.0

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( /* ... */ ),
		),
	}
}

func