This commit is contained in:
@@ -251,6 +251,12 @@ namespace AyaNova.Biz
|
||||
if (string.IsNullOrWhiteSpace(inObj.ListKey))
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "ListKey");
|
||||
|
||||
FilterOptions ListValidFilterOptions = FilterOptionsFromListKey.Get(inObj.ListKey);
|
||||
if (ListValidFilterOptions == null)
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "ListKey", $"ListKey \"{inObj.ListKey}\" is empty or in-valid");
|
||||
}
|
||||
|
||||
if (inObj.ListKey.Length > 255)
|
||||
AddError(ValidationErrorType.LengthExceeded, "ListKey", "255 max");
|
||||
|
||||
@@ -270,11 +276,17 @@ namespace AyaNova.Biz
|
||||
var fld = filterItem["fld"].Value<string>();
|
||||
if (string.IsNullOrWhiteSpace(fld))
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, \"fld\" property is empty and required");
|
||||
//NOTE: have decided not to validate the field names are actually valid as that would involve a lot of fuckery that would probably be unproductive at this point
|
||||
//as this datafilter normally would come straight from our client software that recieves its' list of fields directly from the object anyway
|
||||
//maybe in future it will be more of an issue when it comes to modifications to objects or fields dropped but those errors should be caught by integration tests anyway
|
||||
//and the rest are just outside users
|
||||
|
||||
//validate the field name if we can
|
||||
if (ListValidFilterOptions != null)
|
||||
{
|
||||
|
||||
if (!ListValidFilterOptions.Flds.Exists(x => x.Fld == fld))
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "Filter", $"Filter array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (filterItem["op"] == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"op\" property ");
|
||||
|
||||
30
server/AyaNova/biz/FilterOptionsFromListKey.cs
Normal file
30
server/AyaNova/biz/FilterOptionsFromListKey.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
internal static class FilterOptionsFromListKey
|
||||
{
|
||||
internal static FilterOptions Get(string listKey)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(listKey))
|
||||
return null;
|
||||
|
||||
switch (listKey)
|
||||
{
|
||||
//All listkeys are always lower case
|
||||
|
||||
case "widget":
|
||||
return WidgetBiz.FilterOptions();
|
||||
|
||||
default:
|
||||
return null;//not found
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
}//eons
|
||||
|
||||
@@ -17,14 +17,16 @@ namespace AyaNova.Biz
|
||||
{
|
||||
public static FilterOptions FilterOptions(long localizeToLocaleId = 0)
|
||||
{
|
||||
FilterOptions f = new FilterOptions("Widget");
|
||||
//NOTE: All column names are lowercase to conform with Postgres AyaNova DB which uses lowercase for all identifiers
|
||||
//Also all list keys are lower case for consistency
|
||||
FilterOptions f = new FilterOptions("widget");
|
||||
f.
|
||||
AddField("Name", "WidgetName", AyDataType.Text).
|
||||
AddField("Serial", "WidgetSerial", AyDataType.Text).
|
||||
AddField("DollarAmount", "WidgetDollarAmount", AyDataType.Decimal).
|
||||
AddField("Active", "WidgetActive", AyDataType.Bool).
|
||||
AddField("StartDate", "WidgetStartDate", AyDataType.Date).
|
||||
AddField("EndDate", "WidgetEndDate", AyDataType.Date);
|
||||
AddField("name", "WidgetName", AyDataType.Text).
|
||||
AddField("serial", "WidgetSerial", AyDataType.Text).
|
||||
AddField("dollaramount", "WidgetDollarAmount", AyDataType.Decimal).
|
||||
AddField("active", "WidgetActive", AyDataType.Bool).
|
||||
AddField("startdate", "WidgetStartDate", AyDataType.Date).
|
||||
AddField("enddate", "WidgetEndDate", AyDataType.Date);
|
||||
|
||||
if (localizeToLocaleId != 0)
|
||||
f.Localize(localizeToLocaleId);
|
||||
|
||||
Reference in New Issue
Block a user