using System.Text.Json; using Json.Schema; using StellaOps.Policy.RiskProfile.Schema; namespace StellaOps.Policy.RiskProfile.Validation; public sealed class RiskProfileValidator { private readonly JsonSchema _schema; public RiskProfileValidator() : this(RiskProfileSchemaProvider.GetSchema()) { } public RiskProfileValidator(JsonSchema schema) { _schema = schema ?? throw new ArgumentNullException(nameof(schema)); } public ValidationResults Validate(string json) { if (string.IsNullOrWhiteSpace(json)) { throw new ArgumentException("Risk profile payload is required.", nameof(json)); } using var document = JsonDocument.Parse(json); return _schema.Validate(document.RootElement); } }