|
|
@@ -25,7 +25,6 @@ def is_modern_french_date(field, value, error):
|
|
|
except:
|
|
|
error(field, 'Doit être une date au format jj/mm/aaaa: {}'.format(value))
|
|
|
|
|
|
-
|
|
|
def is_int(field, value, error):
|
|
|
try:
|
|
|
if float(value) != int(value):
|
|
|
@@ -39,6 +38,13 @@ def is_positive_int(field, value, error):
|
|
|
error(field, 'Doit être un nombre entier positif: {}'.format(value))
|
|
|
except (TypeError, ValueError):
|
|
|
error(field, 'Doit être un nombre entier positif: {}'.format(value))
|
|
|
+
|
|
|
+def is_strictly_positive_int(field, value, error):
|
|
|
+ try:
|
|
|
+ if float(value) != int(value) or int(value) <= 0:
|
|
|
+ error(field, 'Doit être un nombre entier positif: {}'.format(value))
|
|
|
+ except (TypeError, ValueError):
|
|
|
+ error(field, 'Doit être un nombre entier positif: {}'.format(value))
|
|
|
|
|
|
def is_multi_int(field, value, error):
|
|
|
|
|
|
@@ -60,6 +66,14 @@ def is_positive_float(field, value, error):
|
|
|
error(field, 'Doit être un nombre décimal positif ({})'.format(value))
|
|
|
except ValueError:
|
|
|
error(field, 'Doit être un nombre décimal positif ({})'.format(value))
|
|
|
+
|
|
|
+def is_strictly_positive_float(field, value, error):
|
|
|
+ try:
|
|
|
+ value = locale.atof(str(value))
|
|
|
+ if value != float(value) or float(value) <= 0:
|
|
|
+ error(field, 'Doit être un nombre décimal positif ({})'.format(value))
|
|
|
+ except ValueError:
|
|
|
+ error(field, 'Doit être un nombre décimal positif ({})'.format(value))
|
|
|
|
|
|
|
|
|
# Ref: http://docs.python-cerberus.org/en/stable/api.html#error-codes
|