Documentation ¶
Index ¶
- func AlsoRequiresOnBoolValues(onValues []bool, expressions ...path.Expression) validator.Bool
- func AlsoRequiresOnStringValues(onValues []string, expressions ...path.Expression) validator.String
- type AlsoRequiresOnValuesValidator
- func (v AlsoRequiresOnValuesValidator) Description(ctx context.Context) string
- func (v AlsoRequiresOnValuesValidator) MarkdownDescription(context.Context) string
- func (v AlsoRequiresOnValuesValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, resp *validator.BoolResponse)
- func (v AlsoRequiresOnValuesValidator) ValidateString(ctx context.Context, req validator.StringRequest, ...)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlsoRequiresOnBoolValues ¶ added in v1.0.0
func AlsoRequiresOnBoolValues(onValues []bool, expressions ...path.Expression) validator.Bool
Example ¶
// Used within a Schema method of a DataSource, Provider, or Resource _ = schema.Schema{ Attributes: map[string]schema.Attribute{ "example_bool_attr": schema.BoolAttribute{ Optional: true, Validators: []validator.Bool{ // Validate other_attr must be configured if this attribute is set to one of [true]. AlsoRequiresOnBoolValues( []bool{ true, }, path.Expressions{ path.MatchRoot("other_attr"), }...), }, }, "other_attr": schema.StringAttribute{ Optional: true, }, }, }
Output:
func AlsoRequiresOnStringValues ¶ added in v1.0.0
func AlsoRequiresOnStringValues(onValues []string, expressions ...path.Expression) validator.String
AlsoRequiresOnValues checks that a set of path.Expression has a non-null value, if the current attribute or block is set to one of the values defined in onValues array.
Relative path.Expression will be resolved using the attribute or block being validated.
Example ¶
// Used within a Schema method of a DataSource, Provider, or Resource _ = schema.Schema{ Attributes: map[string]schema.Attribute{ "example_string_attr": schema.StringAttribute{ Optional: true, Validators: []validator.String{ // Validate other_attr must be configured if this attribute is set to one of ["value1", "value2"]. AlsoRequiresOnStringValues( []string{ "value1", "value2", }, path.Expressions{ path.MatchRoot("other_attr"), }...), }, }, "other_attr": schema.StringAttribute{ Optional: true, }, }, }
Output:
Types ¶
type AlsoRequiresOnValuesValidator ¶
type AlsoRequiresOnValuesValidator struct { OnStringValues []string OnBoolValues []bool PathExpressions path.Expressions }
AlsoRequiresOnValuesValidator is the underlying struct implementing AlsoRequiresOnValue.
func (AlsoRequiresOnValuesValidator) Description ¶
func (v AlsoRequiresOnValuesValidator) Description(ctx context.Context) string
Description implements validator.String.
func (AlsoRequiresOnValuesValidator) MarkdownDescription ¶
func (v AlsoRequiresOnValuesValidator) MarkdownDescription(context.Context) string
MarkdownDescription implements validator.String.
func (AlsoRequiresOnValuesValidator) ValidateBool ¶ added in v1.0.0
func (v AlsoRequiresOnValuesValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, resp *validator.BoolResponse)
ValidateBool implements validator.Bool.
func (AlsoRequiresOnValuesValidator) ValidateString ¶
func (v AlsoRequiresOnValuesValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse)
ValidateString implements validator.String.
Click to show internal directories.
Click to hide internal directories.