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
Copy file name to clipboardExpand all lines: docs/linters.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -485,12 +485,12 @@ The `numericbounds` linter checks that numeric fields (`int32`, `int64`, `float3
485
485
According to Kubernetes API conventions, numeric fields should have bounds checking to prevent values that are too small, negative (when not intended), or too large.
486
486
487
487
This linter ensures that:
488
-
- Numeric fields have both `+kubebuilder:validation:Minimum` and `+kubebuilder:validation:Maximum` markers
489
-
- K8s declarative validation markers (`+k8s:minimum` and `+k8s:maximum`) are also supported
490
-
- Bounds values are within the type's valid range:
491
-
- int32: full int32 range (±2^31-1)
492
-
- int64: JavaScript-safe range (±2^53-1) per Kubernetes API conventions
493
-
- float32/float64: within their respective ranges
488
+
- Numeric fields have both `+k8s:minimum` and `+k8s:maximum` markers
489
+
- Kubebuilder validation markers (`+kubebuilder:validation:Minimum` and `+kubebuilder:validation:Maximum`) are also supported
490
+
- Bounds values are validated:
491
+
- int32: within int32 range (±2^31-1)
492
+
- int64: within JavaScript-safe range (±2^53-1) per K8s API conventions for JSON compatibility
493
+
- float32/float64: marker values are valid (within type ranges)
494
494
495
495
**Note:** While `+k8s:minimum` is documented in the official Kubernetes declarative validation spec, `+k8s:maximum` is not yet officially documented but is supported by this linter for forward compatibility and consistency.
// Kubernetes API conventions enforce JavaScript-safe bounds for int64 (±2^53-1)
191
-
// to ensure compatibility with JavaScript clients
192
-
ifminimum<float64(minSafeInt64) {
193
-
pass.Reportf(field.Pos(), "%s has minimum bound %v that is outside the JavaScript-safe int64 range [%d, %d]. Consider using a string type to avoid precision loss in JavaScript clients", prefix, minimum, int64(minSafeInt64), int64(maxSafeInt64))
194
-
}
195
-
196
-
ifmaximum>float64(maxSafeInt64) {
197
-
pass.Reportf(field.Pos(), "%s has maximum bound %v that is outside the JavaScript-safe int64 range [%d, %d]. Consider using a string type to avoid precision loss in JavaScript clients", prefix, maximum, int64(minSafeInt64), int64(maxSafeInt64))
198
-
}
186
+
// K8s API conventions enforce JavaScript-safe bounds for int64 (±2^53-1)
0 commit comments