From cfd04e3240085f95fd7e2fd7f48f57ecf2a5989e Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 25 Jun 2008 00:12:41 -0300 Subject: [PATCH] Add common Int related validators (refs #20) Is very common to validate a number that must be in the range of an (unsigned) integer of 8/16/32/64 bits. Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64 and UInt64 are provided for that. --- pymin/validation.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pymin/validation.py b/pymin/validation.py index 9219f71..7066898 100644 --- a/pymin/validation.py +++ b/pymin/validation.py @@ -9,6 +9,39 @@ from pymin.item import Item from pymin.validatedclass import Field +class Int8(Int): + min = -128 + max = +127 + +class UInt8(Int): + min = 0 + max = 255 + +class Int16(Int): + min = -32768 + max = +32767 + +class UInt16(Int): + min = 0 + max = 65535 + +class Int32(Int): + min = -2147483648 + max = +2147483647 + +class UInt32(Int): + min = 0 + max = 4294967295 + +class Int64(Int): + min = -9223372036854775808 + max = +9223372036854775807 + +class UInt64(Int): + min = 0 + max = 18446744073709551615 + + class UpOneOf(OneOf): """ Same as :class:`OneOf` but values are uppercased before validation. -- 2.43.0