Module: check_mk
Branch: master
Commit: fa871eca1439125a7f6fc2c1ae610d97667a432d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fa871eca143912…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 9 16:12:06 2012 +0200
new option allow_emtpy for value spec ListOf
---
web/htdocs/valuespec.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index be1d031..546c5d5 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -557,6 +557,7 @@ class ListOf(ValueSpec):
self._add_label = kwargs.get("add_label", _("Add new
element"))
self._movable = kwargs.get("movable", True)
self._totext = kwargs.get("totext")
+ self._allow_empty = kwargs.get("allow_empty", True)
def del_button(self, vp, nr):
js = "valuespec_listof_delete(this, '%s', '%s')" % (vp,
nr)
@@ -655,6 +656,8 @@ class ListOf(ValueSpec):
self._valuespec.validate_datatype(v, varprefix + "_%d" % (n+1))
def validate_value(self, value, varprefix):
+ if not self._allow_empty and len(value) == 0:
+ raise MKUserError(varprefix, _("Please specify at least on
entry"))
for n, v in enumerate(value):
self._valuespec.validate_value(v, varprefix + "_%d" % (n+1))