This commit is contained in:
@@ -5,6 +5,10 @@ Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTQ3NTgwMzg2IiwiZXhwIjoi
|
||||
|
||||
## IMMEDIATE ITEMS
|
||||
|
||||
ValidationErrorTypes.cs is a parallel error code system to ApiErrorCode.cs that seems to originally be intended for form level field validation errors, however similar / same codes
|
||||
are written into apierrorcode and I think it was intended to show textual errors to help developers, however numbers are easier to work with and it's crazy to have two different sets of api level errors for validation etc (and we already have a third set of codes for OPS level errors so two only would be best)
|
||||
|
||||
|
||||
|
||||
Need a sprint to get to a fully testable client with entry form, list and as much as possible all features from COMMON-* specs list
|
||||
Do the stuff in the Client todo first then back to the server as required.
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
The AyaNova API will return an [error response](api-response-format.md#error-responses) when an error condition arises.
|
||||
|
||||
All API error codes wrap and indicate the entire response overall error and are numbers between 2000 and 3000 and are intended to be consumed by software clients or for reference purposes for developers.
|
||||
All API error codes are numbers between 2000 and 3000 and are intended to be consumed by software clients or for reference purposes for developers.
|
||||
|
||||
API error codes are different from [server error codes](ops-error-codes.md) which are intended for AyaNova system operators and related only to the running of the server itself.
|
||||
API error codes are distinct from [server error codes](ops-error-codes.md) which are intended for AyaNova system operators and related only to the running of the server itself.
|
||||
|
||||
Here are all the API level error codes that can be returned by the API server:
|
||||
|
||||
@@ -21,5 +21,14 @@ Here are all the API level error codes that can be returned by the API server:
|
||||
| 2030 | Invalid operation - operation could not be completed, not valid, details in message property |
|
||||
| 2200 | Validation error - general top level indicating object was not valid, specifics in "details" property |
|
||||
| 2201 | Validation error - Field is required but is empty or null |
|
||||
| 2202 | Validation error - Field length exceeded |
|
||||
| 2203 | Validation error - invalid value |
|
||||
| 2202 | Validation error - Field length exceeded. The limit will be returned in the `message` property of the validation error |
|
||||
| 2203 | Validation error - invalid value. Usually an type mismatch or a logical or business rule mismatch (i.e. only certain values are valid for current state of object) |
|
||||
| 2204 | Validation error - Customized form property set to required has an empty value |
|
||||
| 2205 | Validation error - Required property is missing entirely. Usually a development or communications error |
|
||||
| 2206 | Validation error - A text property is required to be unique but an existing record with an identical value was found in the database |
|
||||
|
||||
| StartDateMustComeBeforeEndDate | When an object requires a start and end date the start date must be earlier than the end date |
|
||||
| InvalidValue | Generic error indicating an input object's property is not set correctly |
|
||||
| ReferentialIntegrity | Indicates modifying the object (usually a delete) will break the link to other records in the database. The other records need to be modified before continuing |
|
||||
| InvalidOperation | Indicates the operation is invalid, details provided in the `message` |
|
||||
| NotChangeable | Indicates the attempted property change is invalid because the value is fixed and cannot be changed |
|
||||
@@ -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