int64validator

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MPL-2.0 Imports: 10 Imported by: 199

Documentation

Overview

Package int64validator provides validators for types.Int64 attributes.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.7.0

func All(validators ...validator.Int64) validator.Int64

All returns a validator which ensures that any configured attribute value 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-validators/int64validator"
	"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
	"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)

func main() {
	// Used within a Schema method of a DataSource, Provider, or Resource
	_ = schema.Schema{
		Attributes: map[string]schema.Attribute{
			"example_attr": schema.Int64Attribute{
				Required: true,
				Validators: []validator.Int64{
					// Validate this Int64 value must either be:
					//  - 1.0
					//  - At least 2.0, but not 3.0
					int64validator.Any(
						int64validator.OneOf(1.0),
						int64validator.All(
							int64validator.AtLeast(2.0),
							int64validator.NoneOf(3.0),
						),
					),
				},
			},
		},
	}
}