Map converts the given errors to a map[string]Error, where the keys of the map are the field names.
()
| 55 | // Map converts the given errors to a map[string]Error, where the keys |
| 56 | // of the map are the field names. |
| 57 | func (e Errors) Map() map[string]Error { |
| 58 | if len(e) == 0 { |
| 59 | return nil |
| 60 | } |
| 61 | m := make(map[string]Error, len(e)) |
| 62 | for _, err := range e { |
| 63 | m[err.Field()] = err |
| 64 | } |
| 65 | return m |
| 66 | } |
| 67 | |
| 68 | type errorImpl struct { |
| 69 | field string |