argclz.validator.FloatValidatorBuilder#

class argclz.validator.FloatValidatorBuilder[source]#

Bases: AbstractTypeValidatorBuilder[float]

a float validator

__init__()[source]#

Methods Summary

__init__()

allow_nan([allow])

Allow or disallow NaN (not a number) as a valid float

freeze()

(internal use) return a copy of itself.

in_range(a, b, /)

Enforce an open-interval numeric range (a < value < b)

in_range_closed(a, b, /)

Enforce a closed-interval numeric range (a <= value <= b)

negative([include_zero])

Check if a float value is negative or non-positive

optional()

positive([include_zero])

Check if a float value is positive or non-negative

__call__(value)

Details

freeze()[source]#

(internal use) return a copy of itself.

Return type:

Self

in_range(a, b, /)[source]#

Enforce an open-interval numeric range (a < value < b)

Parameters:
Return type:

Self

in_range_closed(a, b, /)[source]#

Enforce a closed-interval numeric range (a <= value <= b)

Parameters:
Return type:

Self

allow_nan(allow=True)[source]#

Allow or disallow NaN (not a number) as a valid float

Parameters:

allow (bool)

Return type:

Self

positive(include_zero=True)[source]#

Check if a float value is positive or non-negative

Return type:

Self

negative(include_zero=True)[source]#

Check if a float value is negative or non-positive

Return type:

Self

__call__(value)[source]#
Parameters:

value (Any) – type-casted value.

Returns:

True if value pass the validation.

Raises:

ValueError – when value does not pass the validation.

Return type:

bool

optional()#
Return type:

Self