This commit is contained in:
@@ -142,27 +142,27 @@ namespace AyaNova.Biz
|
||||
if (!isNew)
|
||||
{
|
||||
if (inObj.OwnerId == 0)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "OwnerId");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId");
|
||||
}
|
||||
|
||||
// //Owner must be current user, there are no exceptions
|
||||
// if (inObj.OwnerId != UserId)
|
||||
// AddError(ValidationErrorType.InvalidValue, "OwnerId", "OwnerId must be current user Id");
|
||||
// AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "OwnerId", "OwnerId must be current user Id");
|
||||
|
||||
//FormKey required and must be valid
|
||||
if (string.IsNullOrWhiteSpace(inObj.FormKey))
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "FormKey");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "FormKey");
|
||||
else
|
||||
{
|
||||
if (!FormAvailableFields.IsValidFormKey(inObj.FormKey))
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "FormKey");
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "FormKey");
|
||||
}
|
||||
}
|
||||
|
||||
//FormKey must be less than 255 characters
|
||||
if (inObj.FormKey.Length > 255)
|
||||
AddError(ValidationErrorType.LengthExceeded, "FormKey", "255 max");
|
||||
AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "FormKey", "255 max");
|
||||
|
||||
//If name is otherwise OK, check that name is unique
|
||||
if (!PropertyHasErrors("FormKey") && isNew)
|
||||
@@ -170,7 +170,7 @@ namespace AyaNova.Biz
|
||||
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
||||
if (ct.FormCustom.Any(m => m.FormKey == inObj.FormKey && m.Id != inObj.Id))
|
||||
{
|
||||
AddError(ValidationErrorType.NotUnique, "FormKey");
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "FormKey");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,12 +192,12 @@ namespace AyaNova.Biz
|
||||
|
||||
var formFieldItem = v[i];
|
||||
if (formFieldItem["fld"] == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Template", $"Template array item {i}, object is missing required \"fld\" property ");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Template", $"Template array item {i}, object is missing required \"fld\" property ");
|
||||
else
|
||||
{
|
||||
var fldKey = formFieldItem["fld"].Value<string>();
|
||||
if (string.IsNullOrWhiteSpace(fldKey))
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Template", $"Template array item {i}, \"fld\" property is empty and required");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Template", $"Template array item {i}, \"fld\" property is empty and required");
|
||||
|
||||
//validate the field name if we can
|
||||
if (ValidFormFields != null)
|
||||
@@ -205,7 +205,7 @@ namespace AyaNova.Biz
|
||||
|
||||
if (!ValidFormFields.Exists(x => x.Key == fldKey))
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "Template", $"Template array item {i}, fld property value \"{fldKey}\" is not a valid form field value for formKey specified");
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, fld property value \"{fldKey}\" is not a valid form field value for formKey specified");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -223,25 +223,25 @@ namespace AyaNova.Biz
|
||||
{
|
||||
var fieldHideValue = formFieldItem["hide"].Value<bool>();
|
||||
if (!MasterFormField.Hideable && fieldHideValue == true)
|
||||
AddError(ValidationErrorType.InvalidValue, "Template", $"Template array item {i}, \"hide\" property value of \"{fieldHideValue}\" is not valid, this field is core and cannot be hidden");
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"hide\" property value of \"{fieldHideValue}\" is not valid, this field is core and cannot be hidden");
|
||||
}
|
||||
|
||||
if (formFieldItem["type"] != null)
|
||||
{
|
||||
if (!MasterFormField.Custom)
|
||||
AddError(ValidationErrorType.InvalidValue, "Template", $"Template array item {i}, \"type\" property value is not valid, only Custom fields can have types specified");
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value is not valid, only Custom fields can have types specified");
|
||||
else
|
||||
{//It is a custom field, is it a valid type value
|
||||
var templateFieldCustomTypeValue = formFieldItem["type"].Value<string>();
|
||||
if (!ValidCustomFieldTypes.Contains(templateFieldCustomTypeValue))
|
||||
AddError(ValidationErrorType.InvalidValue, "Template", $"Template array item {i}, \"type\" property value of \"{templateFieldCustomTypeValue}\" is not a valid custom field type");
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value of \"{templateFieldCustomTypeValue}\" is not a valid custom field type");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (formFieldItem["required"] == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Template", $"Template array item {i}, object is missing required \"required\" property ");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Template", $"Template array item {i}, object is missing required \"required\" property ");
|
||||
|
||||
|
||||
//NOTE: value of nothing, null or empty is a valid value so no checking for it here
|
||||
@@ -249,7 +249,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
catch (Newtonsoft.Json.JsonReaderException ex)
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "Template", "Template is not valid JSON string: " + ex.Message);
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", "Template is not valid JSON string: " + ex.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user