Software /
code /
prosody
Comparison
util/dataforms.lua @ 5693:ef490e9276df
util.dataforms: Return nil for empty list-mutli responses, to be consistent with other readers
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 14 Jun 2013 00:07:57 +0200 |
parent | 5551:e1e06f1465be |
child | 5776:bd0ff8ae98a8 |
child | 6148:7dcd6f124c93 |
comparison
equal
deleted
inserted
replaced
5682:e7b9ba2d0638 | 5693:ef490e9276df |
---|---|
185 function (field_tag, required) | 185 function (field_tag, required) |
186 local result = {}; | 186 local result = {}; |
187 for value in field_tag:childtags("value") do | 187 for value in field_tag:childtags("value") do |
188 result[#result+1] = value:get_text(); | 188 result[#result+1] = value:get_text(); |
189 end | 189 end |
190 return result, (required and #result == 0 and "Required value missing" or nil); | 190 if #result > 0 then |
191 return result; | |
192 elseif required then | |
193 return nil, "Required value missing"; | |
194 end | |
191 end | 195 end |
192 | 196 |
193 field_readers["text-multi"] = | 197 field_readers["text-multi"] = |
194 function (field_tag, required) | 198 function (field_tag, required) |
195 local data, err = field_readers["list-multi"](field_tag, required); | 199 local data, err = field_readers["list-multi"](field_tag, required); |