From f0267bcf3a4367db5fe8a4f7a0dd247bcb06095b Mon Sep 17 00:00:00 2001 From: Mickael Stanislas Date: Fri, 9 Jun 2023 16:04:27 +0200 Subject: [PATCH] fix: bad func used for nullattributeisoneof and fix description --- boolvalidator/null_if_attribute_is_one_of.go | 2 +- int64validator/null_if_attribute_is_one_of.go | 2 +- internal/null_if_attribute_is_one_of.go | 6 +++--- internal/require_if_attribute_is_one_of.go | 6 +++--- listvalidator/null_if_attribute_is_one_of.go | 2 +- mapvalidator/null_if_attribute_is_one_of.go | 2 +- setvalidator/null_if_attribute_is_one_of.go | 2 +- stringvalidator/null_if_attribute_is_one_of.go | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/boolvalidator/null_if_attribute_is_one_of.go b/boolvalidator/null_if_attribute_is_one_of.go index 1e36b13..836543b 100644 --- a/boolvalidator/null_if_attribute_is_one_of.go +++ b/boolvalidator/null_if_attribute_is_one_of.go @@ -11,7 +11,7 @@ import ( // NullIfAttributeIsOneOf checks if the path.Path attribute contains // one of the exceptedValue attr.Value. func NullIfAttributeIsOneOf(path path.Expression, exceptedValue []attr.Value) validator.Int64 { - return internal.RequireIfAttributeIsOneOf{ + return internal.NullIfAttributeIsOneOf{ PathExpression: path, ExceptedValues: exceptedValue, } diff --git a/int64validator/null_if_attribute_is_one_of.go b/int64validator/null_if_attribute_is_one_of.go index 8411fe2..90bd41d 100644 --- a/int64validator/null_if_attribute_is_one_of.go +++ b/int64validator/null_if_attribute_is_one_of.go @@ -11,7 +11,7 @@ import ( // NullIfAttributeIsOneOf checks if the path.Path attribute contains // one of the exceptedValue attr.Value. func NullIfAttributeIsOneOf(path path.Expression, exceptedValue []attr.Value) validator.Int64 { - return internal.RequireIfAttributeIsOneOf{ + return internal.NullIfAttributeIsOneOf{ PathExpression: path, ExceptedValues: exceptedValue, } diff --git a/internal/null_if_attribute_is_one_of.go b/internal/null_if_attribute_is_one_of.go index 140dd07..d7cbb3a 100644 --- a/internal/null_if_attribute_is_one_of.go +++ b/internal/null_if_attribute_is_one_of.go @@ -46,12 +46,12 @@ func (av NullIfAttributeIsOneOf) Description(_ context.Context) string { var expectedValueDescritpion string for i, expectedValue := range av.ExceptedValues { if i == len(av.ExceptedValues)-1 { - expectedValueDescritpion += expectedValue.String() + expectedValueDescritpion += fmt.Sprintf("%s, ", expectedValue.String()) break } expectedValueDescritpion += expectedValue.String() } - return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is null", av.PathExpression, expectedValueDescritpion) + return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is NULL", av.PathExpression, expectedValueDescritpion) } func (av NullIfAttributeIsOneOf) MarkdownDescription(_ context.Context) string { @@ -63,7 +63,7 @@ func (av NullIfAttributeIsOneOf) MarkdownDescription(_ context.Context) string { } expectedValueDescritpion += fmt.Sprintf("`%s`, ", expectedValue) } - return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is null", av.PathExpression, expectedValueDescritpion) + return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is NULL", av.PathExpression, expectedValueDescritpion) } func (av NullIfAttributeIsOneOf) Validate(ctx context.Context, req NullIfAttributeIsOneOfRequest, res *NullIfAttributeIsOneOfResponse) { diff --git a/internal/require_if_attribute_is_one_of.go b/internal/require_if_attribute_is_one_of.go index 55e4c56..29727f6 100644 --- a/internal/require_if_attribute_is_one_of.go +++ b/internal/require_if_attribute_is_one_of.go @@ -46,12 +46,12 @@ func (av RequireIfAttributeIsOneOf) Description(_ context.Context) string { var expectedValueDescritpion string for i, expectedValue := range av.ExceptedValues { if i == len(av.ExceptedValues)-1 { - expectedValueDescritpion += expectedValue.String() + expectedValueDescritpion += fmt.Sprintf("%s, ", expectedValue.String()) break } expectedValueDescritpion += expectedValue.String() } - return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is required", av.PathExpression, expectedValueDescritpion) + return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is REQUIRED", av.PathExpression, expectedValueDescritpion) } func (av RequireIfAttributeIsOneOf) MarkdownDescription(_ context.Context) string { @@ -63,7 +63,7 @@ func (av RequireIfAttributeIsOneOf) MarkdownDescription(_ context.Context) strin } expectedValueDescritpion += fmt.Sprintf("`%s`, ", expectedValue) } - return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is required", av.PathExpression, expectedValueDescritpion) + return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is REQUIRED", av.PathExpression, expectedValueDescritpion) } func (av RequireIfAttributeIsOneOf) Validate(ctx context.Context, req RequireIfAttributeIsOneOfRequest, res *RequireIfAttributeIsOneOfResponse) { diff --git a/listvalidator/null_if_attribute_is_one_of.go b/listvalidator/null_if_attribute_is_one_of.go index 314c41f..5538321 100644 --- a/listvalidator/null_if_attribute_is_one_of.go +++ b/listvalidator/null_if_attribute_is_one_of.go @@ -11,7 +11,7 @@ import ( // NullIfAttributeIsOneOf checks if the path.Path attribute contains // one of the exceptedValue attr.Value. func NullIfAttributeIsOneOf(path path.Expression, exceptedValue []attr.Value) validator.List { - return internal.RequireIfAttributeIsOneOf{ + return internal.NullIfAttributeIsOneOf{ PathExpression: path, ExceptedValues: exceptedValue, } diff --git a/mapvalidator/null_if_attribute_is_one_of.go b/mapvalidator/null_if_attribute_is_one_of.go index 6383d96..ea0ee67 100644 --- a/mapvalidator/null_if_attribute_is_one_of.go +++ b/mapvalidator/null_if_attribute_is_one_of.go @@ -11,7 +11,7 @@ import ( // NullIfAttributeIsOneOf checks if the path.Path attribute contains // one of the exceptedValue attr.Value. func NullIfAttributeIsOneOf(path path.Expression, exceptedValue []attr.Value) validator.Map { - return internal.RequireIfAttributeIsOneOf{ + return internal.NullIfAttributeIsOneOf{ PathExpression: path, ExceptedValues: exceptedValue, } diff --git a/setvalidator/null_if_attribute_is_one_of.go b/setvalidator/null_if_attribute_is_one_of.go index 79cbc6a..570fdcc 100644 --- a/setvalidator/null_if_attribute_is_one_of.go +++ b/setvalidator/null_if_attribute_is_one_of.go @@ -11,7 +11,7 @@ import ( // NullIfAttributeIsOneOf checks if the path.Path attribute contains // one of the exceptedValue attr.Value. func NullIfAttributeIsOneOf(path path.Expression, exceptedValue []attr.Value) validator.Set { - return internal.RequireIfAttributeIsOneOf{ + return internal.NullIfAttributeIsOneOf{ PathExpression: path, ExceptedValues: exceptedValue, } diff --git a/stringvalidator/null_if_attribute_is_one_of.go b/stringvalidator/null_if_attribute_is_one_of.go index 1c775fc..816108e 100644 --- a/stringvalidator/null_if_attribute_is_one_of.go +++ b/stringvalidator/null_if_attribute_is_one_of.go @@ -11,7 +11,7 @@ import ( // NullIfAttributeIsOneOf checks if the path.Path attribute contains // one of the exceptedValue attr.Value. func NullIfAttributeIsOneOf(path path.Expression, exceptedValue []attr.Value) validator.String { - return internal.RequireIfAttributeIsOneOf{ + return internal.NullIfAttributeIsOneOf{ PathExpression: path, ExceptedValues: exceptedValue, }