From bf112bc7568dd84402507cc6ccb279aa81f47708 Mon Sep 17 00:00:00 2001 From: gwen Date: Thu, 22 Nov 2012 11:53:51 +0100 Subject: [PATCH] custom validator for multis --- tiramisu/option.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tiramisu/option.py b/tiramisu/option.py index a0ec783..642dc7e 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -165,14 +165,14 @@ class Option(HiddenBaseType, DisabledBaseType): :param value: the option's value :param validate: if true enables ``self._validator`` validation """ - # customizing the validator - if validate and value is not None and self._validator is not None: - if not self._validator(value, **self._validator_args): - return False # generic calculation if self.multi == False: # None allows the reset of the value if value != None: + # customizing the validator + if validate and self._validator is not None and \ + not self._validator(value, **self._validator_args): + return False return self._validate(value) else: if not isinstance(value, list): @@ -180,8 +180,12 @@ class Option(HiddenBaseType, DisabledBaseType): "for option {1} which must be a list".format(value, self._name)) for val in value: + # None allows the reset of the value if val != None: - # None allows the reset of the value + # customizing the validator + if validate and self._validator is not None and \ + not self._validator(val, **self._validator_args): + return False if not self._validate(val): return False return True