| 1 |
package errors |
| 2 |
|
| 3 |
import ( |
| 4 |
"net/http" |
| 5 |
) |
| 6 |
|
| 7 |
// PopulateValidationErrors mutates the provided validation errors with additional useful error information, that is |
| 8 |
// not necessarily available when the ValidationError was created and are standard for all errors. |
| 9 |
// Specifically, the RequestPath, SpecPath and RequestMethod are populated. |
| 10 |
func PopulateValidationErrors(validationErrors []*ValidationError, request *http.Request, path string) { |
| 11 |
for _, validationError := range validationErrors { |
| 12 |
validationError.SpecPath = path |
| 13 |
validationError.RequestMethod = request.Method |
| 14 |
validationError.RequestPath = request.URL.Path |
| 15 |
} |
| 16 |
} |