parent
2894efaf46
commit
708eed5817
6 changed files with 62 additions and 14 deletions
|
@ -2,7 +2,23 @@ package types
|
|||
|
||||
import "encoding/json"
|
||||
|
||||
type ValidationError map[string][]string
|
||||
type Source struct {
|
||||
Pointer string `json:"pointer"`
|
||||
}
|
||||
|
||||
type ErrorDetail struct {
|
||||
Source `json:"source"`
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
|
||||
func NewValidationError(attr, message string) ErrorDetail {
|
||||
return ErrorDetail{
|
||||
Source: Source{Pointer: "data/attributes/" + attr},
|
||||
Detail: message,
|
||||
}
|
||||
}
|
||||
|
||||
type ValidationError []ErrorDetail
|
||||
|
||||
func (v ValidationError) Error() string {
|
||||
errs, err := json.Marshal(struct {
|
||||
|
|
Reference in a new issue