# HG changeset patch # User Florian Zeitz # Date 1322850294 -3600 # Node ID 51a7c85751b97e4486ae9c2ff1e73a75c4d8b1bc # Parent f0e72fbe4d6a3b0550ac3310441d9bd72ba95764 util.dataforms: Fix form verification diff -r f0e72fbe4d6a -r 51a7c85751b9 util/dataforms.lua --- a/util/dataforms.lua Wed Nov 30 19:37:13 2011 +0000 +++ b/util/dataforms.lua Fri Dec 02 19:24:54 2011 +0100 @@ -120,12 +120,18 @@ 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_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