@@ -47,7 +47,42 @@ func (v betweenValidator) ValidateFloat32(ctx context.Context, request validator
4747 return
4848 }
4949
50- if request .ConfigValue .IsNull () || request .ConfigValue .IsUnknown () {
50+ if request .ConfigValue .IsNull () {
51+ return
52+ }
53+
54+ if request .ConfigValue .IsUnknown () {
55+ if refn , ok := request .ConfigValue .LowerBoundRefinement (); ok {
56+ if refn .IsInclusive () && refn .LowerBound () > v .max {
57+ response .Diagnostics .Append (validatordiag .InvalidAttributeValueDiagnostic (
58+ request .Path ,
59+ v .Description (ctx ),
60+ fmt .Sprintf ("unknown value that will be at least %f" , refn .LowerBound ()),
61+ ))
62+ } else if ! refn .IsInclusive () && refn .LowerBound () >= v .max {
63+ response .Diagnostics .Append (validatordiag .InvalidAttributeValueDiagnostic (
64+ request .Path ,
65+ v .Description (ctx ),
66+ fmt .Sprintf ("unknown value that will be greater than %f" , refn .LowerBound ()),
67+ ))
68+ }
69+ }
70+
71+ if refn , ok := request .ConfigValue .UpperBoundRefinement (); ok {
72+ if refn .IsInclusive () && refn .UpperBound () < v .min {
73+ response .Diagnostics .Append (validatordiag .InvalidAttributeValueDiagnostic (
74+ request .Path ,
75+ v .Description (ctx ),
76+ fmt .Sprintf ("unknown value that will be at most %f" , refn .UpperBound ()),
77+ ))
78+ } else if ! refn .IsInclusive () && refn .UpperBound () <= v .min {
79+ response .Diagnostics .Append (validatordiag .InvalidAttributeValueDiagnostic (
80+ request .Path ,
81+ v .Description (ctx ),
82+ fmt .Sprintf ("unknown value that will be less than %f" , refn .UpperBound ()),
83+ ))
84+ }
85+ }
5186 return
5287 }
5388
@@ -74,7 +109,42 @@ func (v betweenValidator) ValidateParameterFloat32(ctx context.Context, request
74109 return
75110 }
76111
77- if request .Value .IsNull () || request .Value .IsUnknown () {
112+ if request .Value .IsNull () {
113+ return
114+ }
115+
116+ if request .Value .IsUnknown () {
117+ if refn , ok := request .Value .LowerBoundRefinement (); ok {
118+ if refn .IsInclusive () && refn .LowerBound () > v .max {
119+ response .Error = validatorfuncerr .InvalidParameterValueFuncError (
120+ request .ArgumentPosition ,
121+ v .Description (ctx ),
122+ fmt .Sprintf ("unknown value that will be at least %f" , refn .LowerBound ()),
123+ )
124+ } else if ! refn .IsInclusive () && refn .LowerBound () >= v .max {
125+ response .Error = validatorfuncerr .InvalidParameterValueFuncError (
126+ request .ArgumentPosition ,
127+ v .Description (ctx ),
128+ fmt .Sprintf ("unknown value that will be greater than %f" , refn .LowerBound ()),
129+ )
130+ }
131+ }
132+
133+ if refn , ok := request .Value .UpperBoundRefinement (); ok {
134+ if refn .IsInclusive () && refn .UpperBound () < v .min {
135+ response .Error = validatorfuncerr .InvalidParameterValueFuncError (
136+ request .ArgumentPosition ,
137+ v .Description (ctx ),
138+ fmt .Sprintf ("unknown value that will be at most %f" , refn .UpperBound ()),
139+ )
140+ } else if ! refn .IsInclusive () && refn .UpperBound () <= v .min {
141+ response .Error = validatorfuncerr .InvalidParameterValueFuncError (
142+ request .ArgumentPosition ,
143+ v .Description (ctx ),
144+ fmt .Sprintf ("unknown value that will be less than %f" , refn .UpperBound ()),
145+ )
146+ }
147+ }
78148 return
79149 }
80150
0 commit comments