mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-07-08 05:48:26 +00:00
fix: trim trailing dot from error locations
This commit is contained in:
parent
8aa6989f4c
commit
09e1ebac6a
1 changed files with 2 additions and 2 deletions
|
@ -46,7 +46,7 @@ func validAgainstSchema(ctx *hcontext, label string, schema *schema.Schema, data
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
ctx.AddError(&ErrorDetail{
|
ctx.AddError(&ErrorDetail{
|
||||||
Message: fmt.Errorf("unable to validate against schema: %w", err.(error)).Error(),
|
Message: fmt.Errorf("unable to validate against schema: %w", err.(error)).Error(),
|
||||||
Location: label,
|
Location: strings.TrimSuffix(label, "."),
|
||||||
Value: string(data),
|
Value: string(data),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func validAgainstSchema(ctx *hcontext, label string, schema *schema.Schema, data
|
||||||
// those off to prevent duplicating data. (e.g. see the enum error)
|
// those off to prevent duplicating data. (e.g. see the enum error)
|
||||||
ctx.AddError(&ErrorDetail{
|
ctx.AddError(&ErrorDetail{
|
||||||
Message: strings.TrimPrefix(desc.Description(), desc.Context().String()+" "),
|
Message: strings.TrimPrefix(desc.Description(), desc.Context().String()+" "),
|
||||||
Location: label + strings.TrimPrefix(desc.Field(), "(root)"),
|
Location: strings.TrimSuffix(label+strings.TrimPrefix(desc.Field(), "(root)"), "."),
|
||||||
Value: desc.Value(),
|
Value: desc.Value(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue