1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 05:22:06 +01:00

Merge pull request #467 from Flowdalic/4.4-data-forms

Proposed data form updates for 4.4
This commit is contained in:
Florian Schmaus 2021-06-04 20:58:57 +02:00 committed by GitHub
commit 899813a668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,9 +59,15 @@ public class FillableForm extends FilledForm {
if (formField.isRequired()) { if (formField.isRequired()) {
String fieldName = formField.getFieldName(); String fieldName = formField.getFieldName();
requiredFields.add(fieldName); requiredFields.add(fieldName);
if (formField.hasValueSet()) {
// This is a form field with a default value.
write(formField);
} else {
missingRequiredFields.add(fieldName); missingRequiredFields.add(fieldName);
} }
} }
}
this.requiredFields = Collections.unmodifiableSet(requiredFields); this.requiredFields = Collections.unmodifiableSet(requiredFields);
} }
@ -224,9 +230,6 @@ public class FillableForm extends FilledForm {
if (!getDataForm().hasField(fieldName)) { if (!getDataForm().hasField(fieldName)) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (filledFields.containsKey(fieldName)) {
throw new IllegalArgumentException();
}
// Perform validation, e.g. using XEP-0122. // Perform validation, e.g. using XEP-0122.
// TODO: We could also perform list-* option validation, but this has to take xep122's <open/> into account. // TODO: We could also perform list-* option validation, but this has to take xep122's <open/> into account.