Comparison

util/dataforms.lua @ 9246:397e8e5a2f1f

util.dataforms: Improve default error message for failed datatype validation
author Kim Alvefur <zash@zash.se>
date Mon, 03 Sep 2018 19:44:28 +0200
parent 9243:a4c52e304e6f
child 11026:a086825ed73a
comparison
equal deleted inserted replaced
9245:cc32aae5c7da 9246:397e8e5a2f1f
185 if value ~= nil and validator then 185 if value ~= nil and validator then
186 local valid, ret = validator(value, field); 186 local valid, ret = validator(value, field);
187 if valid then 187 if valid then
188 value = ret; 188 value = ret;
189 else 189 else
190 value, err = nil, ret or field.datatype; 190 value, err = nil, ret or ("Invalid value for data of type " .. field.datatype);
191 end 191 end
192 end 192 end
193 data[field.name], errors[field.name] = value, err; 193 data[field.name], errors[field.name] = value, err;
194 end 194 end
195 end 195 end