Comparison

util/dataforms.lua @ 11630:855b065d5fd6

util.dataforms: Define a integer + "max" datatype
author Kim Alvefur <zash@zash.se>
date Fri, 18 Sep 2020 12:18:51 +0200
parent 11070:f7f30a3464fe
child 11874:84f4c6957d62
comparison
equal deleted inserted replaced
11629:e6e56e2dd996 11630:855b065d5fd6
310 return false, "out of bounds"; 310 return false, "out of bounds";
311 end 311 end
312 return true, n; 312 return true, n;
313 end 313 end
314 314
315 data_validators["pubsub:integer-or-max"] =
316 function (data, field)
317 if data == "max" then
318 return true, data;
319 else
320 return data_validators["xs:integer"](data, field);
321 end
322 end
323
315 324
316 local function get_form_type(form) 325 local function get_form_type(form)
317 if not st.is_stanza(form) then 326 if not st.is_stanza(form) then
318 return nil, "not a stanza object"; 327 return nil, "not a stanza object";
319 elseif form.attr.xmlns ~= "jabber:x:data" or form.name ~= "x" then 328 elseif form.attr.xmlns ~= "jabber:x:data" or form.name ~= "x" then