Message:"The X-Something header must be specified",
},
},
expected:errorTestResult{
statusCode:http.StatusUnprocessableEntity,
contentType:jsonContentType,
body:`[{"classification":"HeaderError","message":"The X-Something header must be specified"}]`,
},
},
{
description:"Custom field error",
errors:Errors{
{
FieldNames:[]string{"month","year"},
Classification:"DateError",
Message:"The month and year must be in the future",
},
},
expected:errorTestResult{
statusCode:http.StatusUnprocessableEntity,
contentType:jsonContentType,
body:`[{"fieldNames":["month","year"],"classification":"DateError","message":"The month and year must be in the future"}]`,
},
},
{
description:"Multiple errors",
errors:Errors{
{
FieldNames:[]string{"foo"},
Classification:ERR_REQUIRED,
Message:"Required",
},
{
FieldNames:[]string{"foo"},
Classification:"LengthError",
Message:"The length of the 'foo' field is too short",
},
},
expected:errorTestResult{
statusCode:http.StatusUnprocessableEntity,
contentType:jsonContentType,
body:`[{"fieldNames":["foo"],"classification":"RequiredError","message":"Required"},{"fieldNames":["foo"],"classification":"LengthError","message":"The length of the 'foo' field is too short"}]`,