This commit is contained in:
2022-01-24 22:38:57 +00:00
parent fadd909c30
commit f1446802f3
2 changed files with 48 additions and 31 deletions

View File

@@ -88,9 +88,11 @@ namespace AyaNova.Biz
{
//It's a simple property on the main object
//use reflection to get the underlying value from the proposed object to be saved
//issue the error on the *Models* property name to mirror how all other server error handling and validation works
//so that client end consumes it properly (fieldkey is just for the UI and showing / hiding overall form values)
object propertyValue = proposedObject.GetType().GetProperty(RequiredPropertyName).GetValue(proposedObject, null);
if (propertyValue == null)
biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, FF.FieldKey);
biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, RequiredPropertyName);
else
{
@@ -98,12 +100,12 @@ namespace AyaNova.Biz
{
if (((System.Collections.Generic.List<string>)propertyValue).Count == 0)
{
biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, FF.FieldKey);
biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, RequiredPropertyName);
}
}
else
if (string.IsNullOrWhiteSpace(propertyValue.ToString()))
biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, FF.FieldKey);
biz.AddError(ApiErrorCode.VALIDATION_CUSTOM_REQUIRED_EMPTY, RequiredPropertyName);
}
}
}