diff --git a/internal/resource_device_switch/device_switch_resource_gen.go b/internal/resource_device_switch/device_switch_resource_gen.go index d4713998..2dd7313b 100644 --- a/internal/resource_device_switch/device_switch_resource_gen.go +++ b/internal/resource_device_switch/device_switch_resource_gen.go @@ -138,7 +138,7 @@ func DeviceSwitchResourceSchema(ctx context.Context) schema.Schema { mistvalidator.RequiredWhenValueIs(path.MatchRelative().AtParent().AtName("protocol"), types.StringValue("udp")), stringvalidator.Any( mistvalidator.ParseInt(0, 65535), - mistvalidator.ParseRangeOfInt(0, 65535), + mistvalidator.ParseRangeOfInt(0, 65535, true), ), }, Default: stringdefault.StaticString("80"), diff --git a/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go b/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go index a052e17a..f6359120 100644 --- a/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go +++ b/internal/resource_org_networktemplate/org_networktemplate_resource_gen.go @@ -138,7 +138,7 @@ func OrgNetworktemplateResourceSchema(ctx context.Context) schema.Schema { mistvalidator.RequiredWhenValueIs(path.MatchRelative().AtParent().AtName("protocol"), types.StringValue("udp")), stringvalidator.Any( mistvalidator.ParseInt(0, 65535), - mistvalidator.ParseRangeOfInt(0, 65535), + mistvalidator.ParseRangeOfInt(0, 65535, true), ), }, Default: stringdefault.StaticString("80"), diff --git a/internal/resource_org_service/org_service_resource_gen.go b/internal/resource_org_service/org_service_resource_gen.go index 0c373dee..b1ce8fae 100644 --- a/internal/resource_org_service/org_service_resource_gen.go +++ b/internal/resource_org_service/org_service_resource_gen.go @@ -166,7 +166,7 @@ func OrgServiceResourceSchema(ctx context.Context) schema.Schema { mistvalidator.RequiredWhenValueIs(path.MatchRelative().AtParent().AtName("protocol"), types.StringValue("udp")), stringvalidator.Any( mistvalidator.ParseInt(0, 65535), - mistvalidator.ParseRangeOfInt(0, 65535), + mistvalidator.ParseRangeOfInt(0, 65535, true), ), }, }, diff --git a/internal/resource_org_wlan/org_wlan_resource_gen.go b/internal/resource_org_wlan/org_wlan_resource_gen.go index 244ecaf6..bc5b818f 100644 --- a/internal/resource_org_wlan/org_wlan_resource_gen.go +++ b/internal/resource_org_wlan/org_wlan_resource_gen.go @@ -959,7 +959,7 @@ func OrgWlanResourceSchema(ctx context.Context) schema.Schema { listvalidator.ValueStringsAre( stringvalidator.Any( mistvalidator.ParseInt(1, 4094), - mistvalidator.ParseRangeOfInt(1, 4094), + mistvalidator.ParseRangeOfInt(1, 4094, false), mistvalidator.ParseVar(), ), ), diff --git a/internal/resource_org_wxtag/org_wxtag_resource_gen.go b/internal/resource_org_wxtag/org_wxtag_resource_gen.go index 77a08978..2b2147eb 100644 --- a/internal/resource_org_wxtag/org_wxtag_resource_gen.go +++ b/internal/resource_org_wxtag/org_wxtag_resource_gen.go @@ -77,7 +77,7 @@ func OrgWxtagResourceSchema(ctx context.Context) schema.Schema { Validators: []validator.String{ stringvalidator.Any( mistvalidator.ParseInt(0, 65535), - mistvalidator.ParseRangeOfInt(0, 65535), + mistvalidator.ParseRangeOfInt(0, 65535, true), ), }, Default: stringdefault.StaticString("0"), diff --git a/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go b/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go index c7d1d077..65223f19 100644 --- a/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go +++ b/internal/resource_site_networktemplate/site_networktemplate_resource_gen.go @@ -138,7 +138,7 @@ func SiteNetworktemplateResourceSchema(ctx context.Context) schema.Schema { mistvalidator.RequiredWhenValueIs(path.MatchRelative().AtParent().AtName("protocol"), types.StringValue("udp")), stringvalidator.Any( mistvalidator.ParseInt(0, 65535), - mistvalidator.ParseRangeOfInt(0, 65535), + mistvalidator.ParseRangeOfInt(0, 65535, true), ), }, Default: stringdefault.StaticString("80"), diff --git a/internal/resource_site_wlan/site_wlan_resource_gen.go b/internal/resource_site_wlan/site_wlan_resource_gen.go index d324e552..fb1a838c 100644 --- a/internal/resource_site_wlan/site_wlan_resource_gen.go +++ b/internal/resource_site_wlan/site_wlan_resource_gen.go @@ -959,7 +959,7 @@ func SiteWlanResourceSchema(ctx context.Context) schema.Schema { listvalidator.ValueStringsAre( stringvalidator.Any( mistvalidator.ParseInt(1, 4094), - mistvalidator.ParseRangeOfInt(1, 4094), + mistvalidator.ParseRangeOfInt(1, 4094, false), mistvalidator.ParseVar(), ), ), diff --git a/internal/resource_site_wxtag/site_wxtag_resource_gen.go b/internal/resource_site_wxtag/site_wxtag_resource_gen.go index 02874646..da072ddb 100644 --- a/internal/resource_site_wxtag/site_wxtag_resource_gen.go +++ b/internal/resource_site_wxtag/site_wxtag_resource_gen.go @@ -80,7 +80,7 @@ func SiteWxtagResourceSchema(ctx context.Context) schema.Schema { Validators: []validator.String{ stringvalidator.Any( mistvalidator.ParseInt(0, 65535), - mistvalidator.ParseRangeOfInt(0, 65535), + mistvalidator.ParseRangeOfInt(0, 65535, true), ), }, Default: stringdefault.StaticString("0"), diff --git a/internal/validators/parse_range_int.go b/internal/validators/parse_range_int.go index 4c789902..61f35a52 100644 --- a/internal/validators/parse_range_int.go +++ b/internal/validators/parse_range_int.go @@ -13,8 +13,9 @@ import ( var _ validator.String = ParseRangeOfIntValidator{} type ParseRangeOfIntValidator struct { - min int - max int + min int + max int + equal_allowed bool } func (o ParseRangeOfIntValidator) Description(_ context.Context) string { @@ -55,7 +56,7 @@ func (o ParseRangeOfIntValidator) ValidateString(_ context.Context, req validato value_one, _ := strconv.Atoi(values[0]) value_two, _ := strconv.Atoi(values[1]) - if value_one >= value_two { + if (!o.equal_allowed && value_one >= value_two) || (o.equal_allowed && value_one > value_two) { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( req.Path, fmt.Sprintf("must be a range of Integers between %s and %s, meaning the first value must be lower than the second value", strconv.Itoa(o.min), strconv.Itoa(o.max)), @@ -65,9 +66,10 @@ func (o ParseRangeOfIntValidator) ValidateString(_ context.Context, req validato } } -func ParseRangeOfInt(min int, max int) validator.String { +func ParseRangeOfInt(min int, max int, equalAlloweds bool) validator.String { return ParseRangeOfIntValidator{ - min: min, - max: max, + min: min, + max: max, + equal_allowed: equalAlloweds, } }