Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlsoRequiresOnValues ¶
func AlsoRequiresOnValues(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_attr": schema.StringAttribute{ Optional: true, Validators: []validator.String{ // Validate other_attr must be configured if this attribute is set to one of ["value1", "value2"]. AlsoRequiresOnValues( []string{ "value1", "value2", }, path.Expressions{ path.MatchRoot("other_attr"), }...), }, }, "other_attr": schema.StringAttribute{ Optional: true, }, }, }
Output:
Types ¶
type AlsoRequiresOnValuesValidator ¶
type AlsoRequiresOnValuesValidator struct { OnValues []string 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) 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.