Skip to content

Commit

Permalink
imp - Check for MEMBER in non-group vCards
Browse files Browse the repository at this point in the history
---

MEMBER is only available in group vCards, so check for their presence in non-group vCards.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 3, 2024
1 parent 30a26f8 commit fa10404
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions VisualCard/Parsers/VcardParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ internal void ValidateCard(Card card)
string[] expectedFields = [.. expectedFieldList];
if (!ValidateComponent(ref expectedFields, out string[] actualFields, card))
throw new InvalidDataException($"The following keys [{string.Join(", ", expectedFields)}] are required. Got [{string.Join(", ", actualFields)}].");

// Check for organization vCards that may not have MEMBER properties
string[] forbiddenOrgFields = [VcardConstants._memberSpecifier];
if (card.CardKind != CardKind.Group && ValidateComponent(ref forbiddenOrgFields, out _, card))
throw new InvalidDataException($"{card.CardKind} vCards are forbidden from having MEMBER properties.");
}

private bool ValidateComponent<TComponent>(ref string[] expectedFields, out string[] actualFields, TComponent component)
Expand Down

0 comments on commit fa10404

Please sign in to comment.