Files
KArtSell.Aegis/docs/Design/kbx-foundation-v60-status-canonical-contract-hardening/backend/Shared/Problems/KbxFastEndpoints.cs
T
kjh2064 3f293d8aa8
deploy / deploy (push) Successful in 1m52s
deploy / notify (push) Successful in 1s
V13-FE-006: consolidate approved UI and contract hardening
2026-08-13 02:41:00 +09:00

24 lines
798 B
C#

using FastEndpoints;
namespace Shared.Problems;
public static class KbxFastEndpoints
{
public static void ConfigureErrors(Config config)
{
config.Errors.ProducesMetadataType = typeof(KbxValidationProblem);
config.Errors.ResponseBuilder = (failures, _, _) =>
KbxValidationProblem.Create(failures.Select(f => new KbxValidationError(
Field: ToCamelCase(f.PropertyName),
RowKey: null,
Code: string.IsNullOrWhiteSpace(f.ErrorCode) ? "VALIDATION_ERROR" : f.ErrorCode,
Message: f.ErrorMessage)).ToArray());
}
private static string? ToCamelCase(string? value)
{
if (string.IsNullOrWhiteSpace(value)) return value;
return char.ToLowerInvariant(value[0]) + value[1..];
}
}