You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
5.1.2.1. Valid values
The value of "maximum" MUST be a JSON number. The value of "exclusiveMaximum" MUST be a boolean.
If "exclusiveMaximum" is present, "maximum" MUST also be present.
5.1.2.2. Conditions for successful validation
Successful validation depends on the presence and value of "exclusiveMaximum":
if "exclusiveMaximum" is not present, or has boolean value false, then the instance is valid if it is lower than, or equal to, the value of "maximum";
if "exclusiveMaximum" has boolean value true, the instance is valid if it is strictly lower than the value of "maximum".
5.1.2.3. Default value
"exclusiveMaximum", if absent, may be considered as being present with boolean value false.
exclusiveMinimum
5.1.3.1. Valid values
The value of "minimum" MUST be a JSON number. The value of "exclusiveMinimum" MUST be a boolean.
If "exclusiveMinimum" is present, "minimum" MUST also be present.
5.1.3.2. Conditions for successful validation
Successful validation depends on the presence and value of "exclusiveMinimum":
if "exclusiveMinimum" is not present, or has boolean value false, then the instance is valid if it is greater than, or equal to, the value of "minimum";
if "exclusiveMinimum" is present and has boolean value true, the instance is valid if it is strictly greater than the value of "minimum".
5.1.3.3. Default value
"exclusiveMinimum", if absent, may be considered as being present with boolean value false.
Describe the solution you'd like
The existing annotations @Min and @Max allow to define the "inclusiveness":
@Target({ ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Min {
/** * @return the element must be higher or equal to */doublevalue();
/** * Specifies whether the specified minimum is inclusive or exclusive. * By default, it is inclusive. * * @return {@code true} if the value must be higher or equal to the specified minimum, * {@code false} if the value must be higher */booleaninclusive() defaulttrue;
}
@Target({ ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Max {
/** * @return value the element must be lower or equal to */doublevalue();
/** * Specifies whether the specified maximum is inclusive or exclusive. * By default, it is inclusive. * * @return {@code true} if the value must be higher or equal to the specified minimum, * {@code false} if the value must be higher */booleaninclusive() defaulttrue;
}
Note that this won't be a breaking change because the above defaults would result in exclusiveMinimum / exclusiveMaximum = false which can be omitted and which is the case at the moment.
Describe alternatives you've considered
We could introduce instead or additionally a new annotation @Schema like in swagger-core, which allows to specify exclusiveMinimum/exclusiveMaximum directly.
But in my opinion it's more important to tie it directly to the value.
@baloo42 I'll try to catch up with those linked issues in the next few days(I wanna dedicate to this the right amount of attention), feel free to ping me directly if I miss something or I'm not answering somewhere(I might just have missed the notification 🙂 ).
No problem - take your time. This issue here has no priority for me. The intention was to get an overview of the missing features and how possible solutions could look like.
Now we have a place where we can discuss solutions to this problem.
Is your enhancement related to a problem? Please describe
At the moment the CRDGenerator does not support exclusiveMinimum/exclusiveMaximum (boolean):
https://kubernetes.io/docs/reference/kubernetes-api/extend-resources/custom-resource-definition-v1/#JSONSchemaProps
exclusiveMaximum
5.1.2.1. Valid values
The value of "maximum" MUST be a JSON number. The value of "exclusiveMaximum" MUST be a boolean.
If "exclusiveMaximum" is present, "maximum" MUST also be present.
5.1.2.2. Conditions for successful validation
Successful validation depends on the presence and value of "exclusiveMaximum":
if "exclusiveMaximum" is not present, or has boolean value false, then the instance is valid if it is lower than, or equal to, the value of "maximum";
if "exclusiveMaximum" has boolean value true, the instance is valid if it is strictly lower than the value of "maximum".
5.1.2.3. Default value
"exclusiveMaximum", if absent, may be considered as being present with boolean value false.
exclusiveMinimum
5.1.3.1. Valid values
The value of "minimum" MUST be a JSON number. The value of "exclusiveMinimum" MUST be a boolean.
If "exclusiveMinimum" is present, "minimum" MUST also be present.
5.1.3.2. Conditions for successful validation
Successful validation depends on the presence and value of "exclusiveMinimum":
if "exclusiveMinimum" is not present, or has boolean value false, then the instance is valid if it is greater than, or equal to, the value of "minimum";
if "exclusiveMinimum" is present and has boolean value true, the instance is valid if it is strictly greater than the value of "minimum".
5.1.3.3. Default value
"exclusiveMinimum", if absent, may be considered as being present with boolean value false.
Describe the solution you'd like
The existing annotations
@Min
and@Max
allow to define the "inclusiveness":Note that this won't be a breaking change because the above defaults would result in
exclusiveMinimum
/exclusiveMaximum
=false
which can be omitted and which is the case at the moment.Describe alternatives you've considered
We could introduce instead or additionally a new annotation
@Schema
like in swagger-core, which allows to specifyexclusiveMinimum/exclusiveMaximum
directly.But in my opinion it's more important to tie it directly to the value.
Additional context
The text was updated successfully, but these errors were encountered: