textual.validation
This module provides a number of classes for validating input.
See Validating Input for details.
Failure
dataclass
¶
Function
¶
Bases: Validator
A flexible validator which allows you to provide custom validation logic.
function
instance-attribute
¶
Function which takes the value to validate and returns True if valid, and False otherwise.
ReturnedFalse
dataclass
¶
validate
¶
validate(value)
Validate that the supplied function returns True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The value to pass into the supplied function. |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
A ValidationResult indicating success if the function returned True, and failure if the function return False. |
Integer
¶
Bases: Number
Validator which ensures the value is an integer which falls within a range.
NotAnInteger
dataclass
¶
validate
¶
validate(value)
Ensure that value is an integer, optionally within a range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The value to validate. |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
The result of the validation. |
Length
¶
Bases: Validator
Validate that a string is within a range (inclusive).
maximum
instance-attribute
¶
The inclusive maximum length of the value, or None if unbounded.
minimum
instance-attribute
¶
The inclusive minimum length of the value, or None if unbounded.
Incorrect
dataclass
¶
validate
¶
validate(value)
Ensure that value falls within the maximum and minimum length constraints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The value to validate. |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
The result of the validation. |