This commit is contained in:
2024-10-23 23:40:31 +00:00
parent f06a23475b
commit 1602b9680d

View File

@@ -16,45 +16,19 @@ namespace AyaNova.Biz
//case 4615
//this is to eliminate the old block optimization to short circuit checking if there is no custom data present
//that wouldn't work anymore with this case resolution and was really not much of an optimization anyway and just
//increased the code surface for no significant savings
if (string.IsNullOrWhiteSpace(customFields))
{
customFields = "{}";
}
//case 4615
bool checkPrefix = !string.IsNullOrEmpty(onlyIfStartsWith);
var FormTemplate = JArray.Parse(formCustom.Template);
var ThisFormCustomFieldsList = FormFieldOptionalCustomizableReference.FormFieldReferenceList(formCustom.FormKey).Where(z => z.IsCustomField == true).Select(z => z.TKey).ToList();
//case 4615 moved this logic into main check below as it would not support startsWith and isn't much of an optimization anyway; less code is best code.
// //If the customFields string is empty then only validation is if any of the fields are required to be filled in
// if (!hasCustomData)
// {
// //iterate the template
// for (int i = 0; i < FormTemplate.Count; i++)
// {
// //get the field customization
// var fldKey = FormTemplate[i]["fld"].Value<string>();
// var fldRequired = FormTemplate[i]["required"].Value<bool>();
// //Check if this is an expected custom field and that it was set to required
// //case 4615
// if (checkPrefix)
// continue;
// if (ThisFormCustomFieldsList.Contains(fldKey) && fldRequired == true)
// {
// //Ok, this field is required but custom fields are all empty so add this error
// biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, fldKey);
// }
// }
// return;
// }
//here we have both a bunch of custom fields presumeably and a form customization so let's get cracking...
//parse the custom fields, it should contain an object with 16 keys
//NOTE: to save bandwidth the actual custom fields look like this:
@@ -86,7 +60,6 @@ namespace AyaNova.Biz
continue;
//It's required, make sure the key is present and contains data
if (CustomFieldData.ContainsKey(InternalCustomFieldName))
{
//validate for now that the custom fields set as required have data in them. Note that we are not validating the sanity of the values, only that they exist