requireExactlyOne method
Implementation
JarObject requireExactlyOne(List<String> fieldNames, [String? message]) {
return addValidator((value) {
if (value == null) return null;
final presentFields = fieldNames
.where((field) => value.containsKey(field) && value[field] != null)
.length;
return presentFields == 1
? null
: (message ??
'Exactly one of these fields must be present: ${fieldNames.join(", ")}');
});
}