maxlength

package
v0.0.0-...-9fe9ade Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

maxlength is an analyzer that checks that all string fields have a maximum length, and that all array fields have a maximum number of items.

String fields that are not otherwise bound in length, through being an enum or formatted in a certain way, should have a maximum length. This ensures that CEL validations on the field are not overly costly in terms of time and memory.

Array fields should have a maximum number of items. This ensures that any CEL validations on the field are not overly costly in terms of time and memory. Where arrays are used to represent a list of structures, CEL rules may exist within the array. Limiting the array length ensures the cardinality of the rules within the array is not unbounded.

For strings, the maximum length can be set using the `kubebuilder:validation:MaxLength` tag. For arrays, the maximum number of items can be set using the `kubebuilder:validation:MaxItems` tag.

For arrays of strings, the maximum length of each string can be set using the `kubebuilder:validation:items:MaxLength` tag, on the array field itself. Or, if the array uses a string type alias, the `kubebuilder:validation:MaxLength` tag can be used on the alias.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     name,
	Doc:      "Checks that all strings formatted fields are marked with a maximum length, and that arrays are marked with max items.",
	Run:      run,
	Requires: []*analysis.Analyzer{inspect.Analyzer, markers.Analyzer},
}

Analyzer is the analyzer for the maxlength package. It checks that strings and arrays have maximum lengths and maximum items respectively.

Functions

func Initializer

func Initializer() initializer

Initializer returns the AnalyzerInitializer for this Analyzer so that it can be added to the registry.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL