V13-FE-011: finalize search list layout slice
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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..];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user