part #2
This commit is contained in:
43
src/Aoc/__Libraries/StellaOps.Aoc/AocWriteGuard.Content.cs
Normal file
43
src/Aoc/__Libraries/StellaOps.Aoc/AocWriteGuard.Content.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace StellaOps.Aoc;
|
||||
|
||||
public sealed partial class AocWriteGuard
|
||||
{
|
||||
private static void ValidateContent(
|
||||
JsonElement document,
|
||||
ImmutableArray<AocViolation>.Builder violations)
|
||||
{
|
||||
if (document.TryGetProperty("content", out var content) && content.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
if (!content.TryGetProperty("raw", out var raw) || raw.ValueKind is JsonValueKind.Null or JsonValueKind.Undefined)
|
||||
{
|
||||
violations.Add(AocViolation.Create(
|
||||
AocViolationCode.MissingProvenance,
|
||||
"/content/raw",
|
||||
"Raw upstream payload must be preserved."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
violations.Add(AocViolation.Create(
|
||||
AocViolationCode.MissingRequiredField,
|
||||
"/content",
|
||||
"Content metadata is required."));
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateLinkset(
|
||||
JsonElement document,
|
||||
ImmutableArray<AocViolation>.Builder violations)
|
||||
{
|
||||
if (!document.TryGetProperty("linkset", out var linkset) || linkset.ValueKind != JsonValueKind.Object)
|
||||
{
|
||||
violations.Add(AocViolation.Create(
|
||||
AocViolationCode.MissingRequiredField,
|
||||
"/linkset",
|
||||
"Linkset metadata is required."));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user