Comparison

util/dataforms.lua @ 4435:ea69296afaef

util.dataforms: Fix verfication for booleans
author Florian Zeitz <florob@babelmonkeys.de>
date Sat, 03 Dec 2011 17:10:48 +0100
parent 4434:51a7c85751b9
child 4884:b8d852aea3ad
comparison
equal deleted inserted replaced
4434:51a7c85751b9 4435:ea69296afaef
250 end 250 end
251 251
252 field_verifiers["boolean"] = 252 field_verifiers["boolean"] =
253 function (data, field_tag, required) 253 function (data, field_tag, required)
254 data = field_readers["text-single"](field_tag); 254 data = field_readers["text-single"](field_tag);
255 if #data == 0 and required then 255 if ((not data) or (#data == 0)) and required then
256 return "Required value missing"; 256 return "Required value missing";
257 end 257 end
258 if data ~= "1" and data ~= "true" and data ~= "0" and data ~= "false" then 258 if data ~= "1" and data ~= "true" and data ~= "0" and data ~= "false" then
259 return "Invalid boolean representation"; 259 return "Invalid boolean representation";
260 end 260 end