MaxValueValidator
This class provides validation logic to ensure that a given input is less than or equal to a specified maximum value. It extends the base validation framework by implementing a comparison check and defining a default error message and code for when the validation fails.
Attributes
| Attribute | Type | Description |
|---|---|---|
| message | string = Ensure this value is less than or equal to %(limit_value)s. | Ensure this value is less than or equal to %(limit_value)s. |
| code | string = max_value | The error code used when validation fails for a value exceeding the maximum limit. |
Constructor
Signature
def MaxValueValidator(
limit_value: Any,
message: str = null
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| limit_value | Any | The maximum value allowed for validation. |
| message | str = null | An optional custom error message to override the default. |
Methods
compare()
@classmethod
def compare(
a: Any,
b: Any
) - > boolean
Determines if the provided value exceeds the specified maximum limit.
Parameters
| Name | Type | Description |
|---|---|---|
| a | Any | The input value being validated for its magnitude. |
| b | Any | The upper bound limit value to compare against. |
Returns
| Type | Description |
|---|---|
boolean | True if the input value 'a' is strictly greater than the limit 'b', indicating a validation failure. |