if not need, don't validate

This commit is contained in:
Emmanuel Garette 2013-05-10 16:00:46 +02:00
parent c13846238d
commit c91e7eff97
1 changed files with 22 additions and 23 deletions

View File

@ -258,9 +258,9 @@ class Option(BaseInformation):
# generic calculation # generic calculation
if context is not None: if context is not None:
descr = context.cfgimpl_get_description() descr = context.cfgimpl_get_description()
if validate:
if not self._multi: if not self._multi:
if value is not None and ((validate and if value is not None and ((self._validator is not None and
self._validator is not None and
not val_validator()) or not val_validator()) or
not self._validate(value)): not self._validate(value)):
raise ValueError(_("invalid value {0} for option {1}" raise ValueError(_("invalid value {0} for option {1}"
@ -274,8 +274,7 @@ class Option(BaseInformation):
self._name)) self._name))
for index in range(0, len(value)): for index in range(0, len(value)):
val = value[index] val = value[index]
if val is not None and ((validate and if val is not None and ((self._validator is not None and
self._validator is not None and
not val_validator()) or not val_validator()) or
not self._validate(val)): not self._validate(val)):
raise ValueError(_("invalid value {0} for option {1}" raise ValueError(_("invalid value {0} for option {1}"