This commit is contained in:
@@ -98,7 +98,7 @@ namespace AyaNova.Api.ControllerHelpers
|
||||
//var vErrors = modelState.Keys.SelectMany(key => modelState[key].Errors);
|
||||
foreach (var key in modelState.Keys)
|
||||
{
|
||||
var vErrors=modelState[key].Errors;
|
||||
var vErrors = modelState[key].Errors;
|
||||
foreach (ModelError m in vErrors)
|
||||
{
|
||||
string msg = "";
|
||||
@@ -110,8 +110,9 @@ namespace AyaNova.Api.ControllerHelpers
|
||||
{
|
||||
msg += "Exception: " + m.Exception.Message;
|
||||
}
|
||||
|
||||
Error.Details.Add(new ApiDetailError() { Code = ((int)ApiErrorCode.VALIDATION_FAILED).ToString(), Target = key, Message = msg, Error=ApiErrorCode.VALIDATION_FAILED.ToString() });
|
||||
//example this produces
|
||||
//{"error":{"code":"2200","details":[{"code":"2200","message":"Exception: Error converting value \"\" to type 'AyaNova.Biz.AuthorizationRoles'. Path 'roles', line 1, position 146.","target":"roles","error":"VALIDATION_FAILED"}],"message":"Object did not pass validation"}}
|
||||
Error.Details.Add(new ApiDetailError() { Code = ((int)ApiErrorCode.VALIDATION_FAILED).ToString(), Target = key, Message = msg, Error = ApiErrorCode.VALIDATION_INVALID_VALUE.ToString() });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ namespace AyaNova.Biz
|
||||
|
||||
public enum ValidationErrorType
|
||||
{
|
||||
RequiredPropertyEmpty = 1,
|
||||
LengthExceeded = 2,
|
||||
NotUnique = 3,
|
||||
Now_api_code_2201_RequiredPropertyEmpty = 1,
|
||||
Now_api_code_2202_LengthExceeded = 2,
|
||||
Now_api_code_2206_NotUnique = 3,
|
||||
StartDateMustComeBeforeEndDate = 4,
|
||||
InvalidValue = 5,
|
||||
ReferentialIntegrity = 6,
|
||||
InvalidOperation = 7,
|
||||
NotChangeable=8,
|
||||
RequiredPropertyMissing = 9,
|
||||
CustomRequiredPropertyEmpty = 10
|
||||
Now_api_code_2205_RequiredPropertyMissing = 9,
|
||||
Now_api_code_2204_CustomRequiredPropertyEmpty = 10
|
||||
|
||||
//!! NOTE - UPDATE api-validation-error-codes.md documentation when adding items
|
||||
|
||||
|
||||
Reference in New Issue
Block a user