Skip to main content

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

AttributeTypeDescription
messagestring = Ensure this value is less than or equal to %(limit_value)s.Ensure this value is less than or equal to %(limit_value)s.
codestring = max_valueThe 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

NameTypeDescription
limit_valueAnyThe maximum value allowed for validation.
messagestr = nullAn 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

NameTypeDescription
aAnyThe input value being validated for its magnitude.
bAnyThe upper bound limit value to compare against.

Returns

TypeDescription
booleanTrue if the input value 'a' is strictly greater than the limit 'b', indicating a validation failure.