summaryrefslogtreecommitdiffstats
path: root/lib/modelfunctions.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/modelfunctions.lua')
-rw-r--r--lib/modelfunctions.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua
index 0648f23..1cd19a9 100644
--- a/lib/modelfunctions.lua
+++ b/lib/modelfunctions.lua
@@ -59,3 +59,27 @@ function getfiledetails(file)
end
return cfe({ type="group", value={filename=filename, filecontent=filecontent, filesize=filesize, mtime=mtime}, label="Config file details" })
end
+
+function validateselect(select)
+ for i,option in ipairs(select.option) do
+ if option == select.value then
+ return true
+ end
+ end
+ select.errtxt = "Invalid selection"
+ return false
+end
+
+function validatemulti(multi)
+ local reverseoption = {}
+ for i,option in ipairs(multi.option) do
+ reverseoption[option] = i
+ end
+ for i,value in ipairs(multi.value) do
+ if not reverseoption[value] then
+ multi.errtxt = "Invalid selection"
+ return false
+ end
+ end
+ return true
+end