enrichCustomDoc static method
Enrich a custom document with properties_validators and standard doc info. Returns a new map with merged fields (like React's enrichedCustomDocuments).
Implementation
static Map<String, dynamic> enrichCustomDoc(
Map<String, dynamic> doc,
List<dynamic> propertiesValidators,
) {
final key = doc['key'] as String? ?? '';
// 1. Try properties_validators (by key match)
Map<String, dynamic>? validatorExtra;
for (final v in propertiesValidators) {
if (v is Map<String, dynamic> && v['key'] == key) {
validatorExtra = v;
break;
}
}
// 2. Try standard doc list (by value match → get labelKey)
final standardLabelKey = standardDocLabelKeys[key];
final enriched = <String, dynamic>{
if (standardLabelKey != null) 'labelKey': standardLabelKey,
...doc,
if (validatorExtra != null) ...validatorExtra,
};
return enriched;
}