Kim Alvefur
43531740f9
util: Prefix module imports with prosody namespace
3 years ago
Kim Alvefur
ff2e0641b9
util.dataforms: Encode size attributes as integers in XEP-0221 media element
...
Otherwise very large fields would be serialized in e notation
4 years ago
Kim Alvefur
1a0be02fe8
util.dataforms: Ensure larger integers are serialized as such
...
Assumes that most number fields are integers, as most numeric types
listed in XEP-0122 are, as are all such fields in Prosody as of this.
Otherwise %g produces something like 1.1259e+15
4 years ago
Kim Alvefur
f956b07ca0
util.dataforms: Turn number values into timestamps for datetime fields
...
Makes it symmetric with parsing.
4 years ago
Kim Alvefur
fc677f515f
util.dataforms: Coerce number values for boolean fields
...
Makes more sense than coercing to a string, which would always be
truthy.
4 years ago
Kim Alvefur
851127ecd7
util.dataforms: Add support for datetime field types via XEP-0122
4 years ago
Kim Alvefur
351a197fbd
util.dataforms: Define a integer + "max" datatype
5 years ago
Kim Alvefur
bc20052a9b
util.dataforms: Add support for validating (integer) ranges
6 years ago
Kim Alvefur
1c0e4300ab
util.dataforms: Convert media element sizes to avoid error on Lua 5.3
...
The stanza API does not accept number values and threw an error due to
the height and width attributes of the media element (XEP-0221).
This part had no test coverage previously, explaining why it was not
discovered until now.
5 years ago
Kim Alvefur
715b488722
util.dataforms: Improve default error message for failed datatype validation
7 years ago
Kim Alvefur
9c1528bf2e
util.dataforms: Add support for XEP-0122: Data Forms Validation
...
Initially only basic validation of xs:integer
7 years ago
Kim Alvefur
3da47d7dde
util.dataforms: Allow field names to be different from the 'var' attribute
...
This should allow the usage of long prefixes and namespace-like names to
be contained to the XML representation of the form, so that the code can
use more convenient names.
7 years ago
Matthew Wild
03b4a9a938
util.dataforms: Don't include list options in result forms ( fixes #983 )
8 years ago
Kim Alvefur
876b96659c
util.dataforms: Allow passing the current values to be used in stead of omitted fields
8 years ago
Kim Alvefur
2f1b93f5e9
util.dataforms: Normalize indentation
8 years ago
Kim Alvefur
4e6aa6ffd2
util.dataforms: Only allow overriding of options when passed via the :form method
8 years ago
Kim Alvefur
6b55f14950
util.dataforms: Allow overriding default options even if the form has such
8 years ago
Kim Alvefur
414778ee5d
util.dataforms: Allow passing dynamically generated options as values (fixes traceback)
...
This is awkward but there’s currently no better way to do this, short of
dynamically generating the entire form each time
8 years ago
Kim Alvefur
383dc3fbfd
util.dataforms: Exclude descriptive text fields from forms of type 'submit'
...
The receiving end presumably already have the original form, so these
potentially long text fields are of little value.
8 years ago
Kim Alvefur
03cb429034
util.dataforms: Skip all fields for the 'cancel' form type
...
XEP-0004 says:
> a data form of type "cancel" SHOULD NOT contain any <field/> elements.
The title and instructions don't seem to be of much value in this case
either.
I'm not aware of 'cancel' being used anywhere, so this should break
nothing. Early return is always nice.
8 years ago
Kim Alvefur
90a519fc70
util.dataforms: Only include options in 'form' type forms
...
Options should not be needed in other types of forms.
8 years ago
Kim Alvefur
aa1b2624bd
util.dataforms: Set default value for form type argument
8 years ago
Kim Alvefur
ef485bd2af
util.dataforms: Detach generation of options from values ( fixes #1177 )
8 years ago
Kim Alvefur
9917c35bb6
util.dataforms: Ensure fields have names when collecting data (fixes traceback, thanks Martin)
8 years ago
Matthew Wild
bdb4a84ec4
util.dataforms: More robust handling of field values, especially booleans
...
Ensure that a non-nil data[field_name] always overrides the field's default,
and that values of boolean 'false' are always rendered in the form.
8 years ago
Kim Alvefur
cecc562ac0
util.dataforms: Add support for field descriptions in <desc>
8 years ago
Kim Alvefur
a7448e43e0
util.dataforms: Add a simple function for identifying form types
...
This is meant to allow identifying forms without parsing them
completely.
8 years ago
Kim Alvefur
5b1a236029
util.dataforms: Remove string conversion to let util.stanza validate types
8 years ago
Kim Alvefur
43b814a83b
vairious: Add annotation when an empty environment is set [luacheck]
8 years ago
Kim Alvefur
6b2c577b20
util.dataforms: Fix including default value for list-single when given as field.value[].default
10 years ago
Kim Alvefur
99a7a645f1
util.dataforms: Allow separation of options from values in list fields
10 years ago
Kim Alvefur
db9b82199f
util.dataforms: Track which fields are included in a form
10 years ago
Kim Alvefur
e91df7d788
util.dataforms: Fix interaction of required fields and empty string values ( fixes #521 )
10 years ago
Kim Alvefur
5739f89a5d
util.dataforms: Refactor parsing to reuse simple text parser instead of duplicate code
10 years ago
Matthew Wild
d0741cdda2
util.dataforms: Rename unused loop counter to '_' [luacheck]
11 years ago
Matthew Wild
fd58c2c49c
util.dataforms: Remove unused import of pairs() (thanks luacheck)
11 years ago
Kim Alvefur
eaa823a597
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
11 years ago
daurnimator
810491af12
util/dataforms: Make sure we iterate over field tags
11 years ago
Kim Alvefur
ef460cbd97
util.dataforms: Add support for XEP-0221: Data Forms Media Element
12 years ago
Florian Zeitz
1d833bb807
Remove all trailing whitespace
13 years ago
Florian Zeitz
17bc3cc408
util.dataforms: Return nil for empty list-mutli responses, to be consistent with other readers
13 years ago
Florian Zeitz
8cc295b34a
util.dataforms: Add support for generating type='fixed' fields
13 years ago
Florian Zeitz
49d3586dc1
util.dataforms: Fix parsing of -multi fields
14 years ago
Kim Alvefur
644b8615f3
util.dataforms: Don't return invalid JIDs in jid-single.
14 years ago
Kim Alvefur
9cf153e1bc
util.dataforms: Fix validation of booleans.
14 years ago
Kim Alvefur
3373f129a7
util.dataforms: Do field validation and normalization in field readers.
14 years ago
Florian Zeitz
df36a97275
util.dataforms: Fix verfication for booleans
14 years ago
Florian Zeitz
fef2f58cb6
util.dataforms: Fix verfication for booleans
14 years ago
Florian Zeitz
2dae99da75
util.dataforms: Fix form verification
14 years ago
Florian Zeitz
665853d999
util.dataforms: Fix form verification
14 years ago