This commit is contained in:
@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.JsonPatch;
|
||||
using EnumsNET;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
@@ -221,9 +222,9 @@ namespace AyaNova.Biz
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "OwnerId");
|
||||
}
|
||||
|
||||
//Owner must be current user, there are no exceptions
|
||||
if (inObj.OwnerId != UserId)
|
||||
AddError(ValidationErrorType.InvalidValue, "OwnerId", "OwnerId must be current user Id");
|
||||
// //Owner must be current user, there are no exceptions
|
||||
// if (inObj.OwnerId != UserId)
|
||||
// AddError(ValidationErrorType.InvalidValue, "OwnerId", "OwnerId must be current user Id");
|
||||
|
||||
//Name required
|
||||
if (string.IsNullOrWhiteSpace(inObj.Name))
|
||||
@@ -249,6 +250,30 @@ namespace AyaNova.Biz
|
||||
if (inObj.ListKey.Length > 255)
|
||||
AddError(ValidationErrorType.LengthExceeded, "ListKey", "255 max");
|
||||
|
||||
//Filter json must parse
|
||||
if (!string.IsNullOrWhiteSpace(inObj.Filter))
|
||||
{
|
||||
try
|
||||
{
|
||||
var v = JArray.Parse(inObj.Filter);
|
||||
for (int i = 0; i < v.Count; i++)
|
||||
{
|
||||
var filterItem = v[i];
|
||||
if (filterItem["fld"] == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"fld\" property ");
|
||||
if (filterItem["op"] == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"op\" property ");
|
||||
if (filterItem["value"] == null)
|
||||
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"value\" property ");
|
||||
}
|
||||
}
|
||||
catch (Newtonsoft.Json.JsonReaderException ex)
|
||||
{
|
||||
AddError(ValidationErrorType.InvalidValue, "Filter", "Filter is not valid JSON string: " + ex.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user