diff options
author | Kim Alvefur <zash@zash.se> | 2018-09-01 03:10:09 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-09-01 03:10:09 +0200 |
commit | 9c1528bf2e103e50476f6a3dde68f58135240b79 (patch) | |
tree | c3b5e65c45bcd1366d6e884ff5420c147a19b015 /spec | |
parent | 3da47d7dde637947a736debd4c350bd7eaaa8198 (diff) | |
download | prosody-9c1528bf2e103e50476f6a3dde68f58135240b79.tar.gz prosody-9c1528bf2e103e50476f6a3dde68f58135240b79.zip |
util.dataforms: Add support for XEP-0122: Data Forms Validation
Initially only basic validation of xs:integer
Diffstat (limited to 'spec')
-rw-r--r-- | spec/util_dataforms_spec.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua index 123b9f8a..89759035 100644 --- a/spec/util_dataforms_spec.lua +++ b/spec/util_dataforms_spec.lua @@ -401,5 +401,27 @@ describe("util.dataforms", function () assert.equal("hello", x:find"field/value#"); end); end); + + describe("validation", function () + local f = dataforms.new { + { + name = "number", + type = "text-single", + datatype = "xs:integer", + }, + }; + + it("works", function () + local d = f:data(f:form({number = 1})); + assert.equal(1, d.number); + end); + + it("works", function () + local d,e = f:data(f:form({number = "nan"})); + assert.not_equal(1, d.number); + assert.table(e); + assert.string(e.number); + end); + end); end); |