aboutsummaryrefslogtreecommitdiffstats
path: root/util/dataforms.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-01-22 22:55:49 +0000
committerMatthew Wild <mwild1@gmail.com>2012-01-22 22:55:49 +0000
commit4d7ce5ef98953b67c80cc7f2fc347f01ad9cdd4e (patch)
treeacc1b9c5576f0ba21b56fd5b133a4a173798d042 /util/dataforms.lua
parentb803655fc3922d51ccfb44eebe8540e3ba562b2b (diff)
parent075f0cbd7c732c108e03ec8596e9934db7b8b06a (diff)
downloadprosody-4d7ce5ef98953b67c80cc7f2fc347f01ad9cdd4e.tar.gz
prosody-4d7ce5ef98953b67c80cc7f2fc347f01ad9cdd4e.zip
Merge with trunk
Diffstat (limited to 'util/dataforms.lua')
-rw-r--r--util/dataforms.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index e4d24cf6..d4a1865c 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -120,12 +120,18 @@ function form_t.data(layout, stanza)
end
end
- local reader = field_readers[field.type];
- local verifier = field.verifier or field_verifiers[field.type];
- if reader then
- data[field.name] = reader(tag);
- if verifier then
- errors[field.name] = verifier(data[field.name], tag, field.required);
+ if not tag then
+ if field.required then
+ errors[field.name] = "Required value missing";
+ end
+ else
+ local reader = field_readers[field.type];
+ local verifier = field.verifier or field_verifiers[field.type];
+ if reader then
+ data[field.name] = reader(tag);
+ if verifier then
+ errors[field.name] = verifier(data[field.name], tag, field.required);
+ end
end
end
end
@@ -161,7 +167,7 @@ field_readers["jid-single"] =
field_verifiers["jid-single"] =
function (data, field_tag, required)
- if #data == 0 and required then
+ if ((not data) or (#data == 0)) and required then
return "Required value missing";
end
if not jid_prep(data) then
@@ -246,7 +252,7 @@ field_readers["boolean"] =
field_verifiers["boolean"] =
function (data, field_tag, required)
data = field_readers["text-single"](field_tag);
- if #data == 0 and required then
+ if ((not data) or (#data == 0)) and required then
return "Required value missing";
end
if data ~= "1" and data ~= "true" and data ~= "0" and data ~= "false" then