diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-07-07 15:38:35 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-07-07 15:38:35 +0000 |
commit | fe6a6653a3651d5f31bf75b23f96d570496737d9 (patch) | |
tree | 7802467a04562fc8b78bb8353ca1636b8f0467de /lib/modelfunctions.lua | |
parent | 014556f6bc79658baf5e2babd78cbd6e1dcf4442 (diff) | |
download | acf-core-fe6a6653a3651d5f31bf75b23f96d570496737d9.tar.bz2 acf-core-fe6a6653a3651d5f31bf75b23f96d570496737d9.tar.xz |
Added errtxt to viewfunctions command result and added some validation code to modelfunctions.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1285 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/modelfunctions.lua')
-rw-r--r-- | lib/modelfunctions.lua | 24 |
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 |