Files
git.stella-ops.org/src/Aoc/__Libraries/StellaOps.Aoc/AocWriteGuard.Content.cs
2026-02-04 19:59:20 +02:00

44 lines
1.4 KiB
C#

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."));
}
}
}