Diff

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
line wrap: on
line diff
--- a/util/dataforms.lua	Fri Jun 25 15:17:37 2021 +0200
+++ b/util/dataforms.lua	Fri Sep 18 12:18:51 2020 +0200
@@ -312,6 +312,15 @@
 		return true, n;
 	end
 
+data_validators["pubsub:integer-or-max"] =
+	function (data, field)
+		if data == "max" then
+			return true, data;
+		else
+			return data_validators["xs:integer"](data, field);
+		end
+	end
+
 
 local function get_form_type(form)
 	if not st.is_stanza(form) then