Skip to content

Commit

Permalink
Update Parser.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Dec 3, 2024
1 parent 1d451d9 commit fda1072
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/AustralianProtectiveMarkings/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ public static ProtectiveMarking ParseProtectiveMarking(string input)
throw new($"Only a single DOWNTO is allowed. Input: {input}");
}

if (downToItems.Count == 0 && expiresItems.Count == 0)
if (downToItems.Count == 0 &&
expiresItems.Count == 0)
{
return null;
}

if (downToItems.Count == 0 || expiresItems.Count == 0)
if (downToItems.Count == 0 ||
expiresItems.Count == 0)
{
throw new($"EXPIRES and DOWNTO cannot be defined without the other. Input: {input}");
}
Expand All @@ -111,15 +113,17 @@ static void ValidateOrder(string input, List<string> keys)
{
var ordered = keys
.OrderBy(_ => order.IndexOf(_));
if (!ordered.SequenceEqual(keys))
if (ordered.SequenceEqual(keys))
{
throw new($"""
Incorrect order.
Order must be: {string.Join(", ", order)}.
Order is: {string.Join(", ", keys)}.
Input: {input}
""");
return;
}

throw new($"""
Incorrect order.
Order must be: {string.Join(", ", order)}.
Order is: {string.Join(", ", keys)}.
Input: {input}
""");
}

static Classification ReadClassification(string input, List<Pair> pairs)
Expand Down

0 comments on commit fda1072

Please sign in to comment.