🛡️ Input Validation¶
result ar Input-Valitherung.
Attributes:
Name | Type | Description |
---|---|---|
valid | bool | Ob Input gültig is |
sanitized_value | Any | Beraigte Version of the Inputs |
errors | Optional[List[str]] | lis from Valitherungsfehlern |
warnings | Optional[List[str]] | lis from warningen |
metadata | Optional[Dict[str, Any]] | Tosätzliche metadata tor Valitherung |
Functions¶
__post_init__()
¶
Post-initialization for Default-valuee.
add_error(message, severity=ValidationSeverity.ERROR)
¶
Fügt Valitherungsfehler hinto.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | str | errormeldung | required |
severity | ValidationSeverity | Schweregrad of the errors | ERROR |
Source code in kei_agent/input_validation.py
Bases: ABC
Abstrakte Basisklasse for Input-Validatoren.
Definiert Interface for all Validator-Implementierungen with gemasamen functionalitäten.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the Validators | required |
required | bool | Ob Input erforthelich is | True |
Source code in kei_agent/input_validation.py
Functions¶
validate(value)
abstractmethod
¶
Validates Input-value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Any | To valitherenthe value | required |
Returns:
Type | Description |
---|---|
ValidationResult | Valitherungsergebnis |
Bases: BaseValidator
Validator for string-Inputs with Pattern-Matching and Satitization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the Validators | required |
min_length | Optional[int] | Minimale string-Länge | None |
max_length | Optional[int] | Maximale string-Länge | None |
pattern | Optional[Union[str, Pattern]] | Erlaubtes Pattern (Regex) | None |
allowed_chars | Optional[str] | Erlaubte Zeichen | None |
forbidthe_patterns | Optional[List[Union[str, Pattern]]] | Verbotene Patterns | None |
satitize_html | bool | HTML-Satitization aktivieren | True |
satitize_sql | bool | SQL-Injection-Schutz aktivieren | True |
**kwargs | Any | Tosätzliche parameters for BaseValidator | {} |
Source code in kei_agent/input_validation.py
Functions¶
validate(value)
¶
Validates string-Input.
Source code in kei_agent/input_validation.py
Bases: BaseValidator
Validator for naroattheische Inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the Validators | required |
min_value | Optional[Union[int, float]] | Minimaler value | None |
max_value | Optional[Union[int, float]] | Maximaler value | None |
integer_only | bool | Nur Gatzzahlen erlauben | False |
positive_only | bool | Nur positive Zahlen erlauben | False |
**kwargs | Any | Tosätzliche parameters for BaseValidator | {} |
Source code in kei_agent/input_validation.py
Functions¶
validate(value)
¶
Validates naroattheischen Input.
Source code in kei_agent/input_validation.py
Bases: BaseValidator
Validator for JSON-Inputs with Schema-Valitherung.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the Validators | required |
max_depth | int | Maximale Verschachtelungstiefe | 10 |
max_size | int | Maximale JSON-Größe in Bytes | 1024 * 1024 |
allowed_types | Optional[List[type]] | Erlaubte Python-typeen | None |
**kwargs | Any | Tosätzliche parameters for BaseValidator | {} |
Source code in kei_agent/input_validation.py
Functions¶
validate(value)
¶
Validates JSON-Input.
Source code in kei_agent/input_validation.py
Validator for komplexe objecte with mehreren Felthen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the Validators | required |
Source code in kei_agent/input_validation.py
Functions¶
add_field(field_name, validator)
¶
Fügt Feld-Validator hinto.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name | str | Name of the Felof the | required |
validator | BaseValidator | Validator for the Feld | required |
Source code in kei_agent/input_validation.py
validate(data)
¶
Validates komplexes object.
Source code in kei_agent/input_validation.py
Haupt-Validator-class for Enterprise Input Validation.
Source code in kei_agent/input_validation.py
Functions¶
register_validator(name, validator)
¶
Regisers Validator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the Validators | required |
validator | BaseValidator | Validator-instatce | required |
validate(validator_name, value)
¶
Validates value with specificm Validator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validator_name | str | Name of the Validators | required |
value | Any | To valitherenthe value | required |
Returns:
Type | Description |
---|---|
ValidationResult | Valitherungsergebnis |
Raises:
Type | Description |
---|---|
ValidationError | If Validator not gefatthe |
Source code in kei_agent/input_validation.py
validate_agent_operation(operation, data)
¶
Validates agent operation-Input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
operation | str | operation name | required |
data | Dict[str, Any] | operation data | required |
Returns:
Type | Description |
---|---|
ValidationResult | Valitherungsergebnis |
Source code in kei_agent/input_validation.py
Gibt globalen Input Validator torück.
Returns:
Type | Description |
---|---|
InputValidator | Input Validator instatce |