namespace New.Application.WriteThrough;
///
/// A single portal-shaped field error, after the write-through translator has
/// mapped a legacy `veld`/`code`/`melding` triple. only
/// carries the raw legacy message, and only for codes the translator did not
/// recognize - see the translator's class-level comment on why it must never
/// invent business meaning for a code it doesn't know.
///
public sealed record PortalFieldError(string Field, string Message, string? Detail = null);
public enum WriteThroughOutcomeKind
{
Success,
ValidationFailed,
Conflict,
NotFound,
}
public sealed record WriteThroughOutcome(WriteThroughOutcomeKind Kind, IReadOnlyList? Errors = null)
{
public static readonly WriteThroughOutcome Success = new(WriteThroughOutcomeKind.Success);
public static readonly WriteThroughOutcome Conflict = new(WriteThroughOutcomeKind.Conflict);
public static readonly WriteThroughOutcome NotFound = new(WriteThroughOutcomeKind.NotFound);
public static WriteThroughOutcome ValidationFailed(IReadOnlyList errors) =>
new(WriteThroughOutcomeKind.ValidationFailed, errors);
}