| | |
| | | return SimpleValidate(propertyInfos, data); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éªè¯å®ä½åæ° |
| | | /// </summary> |
| | | /// <typeparam name="T"></typeparam> |
| | | /// <param name="data"></param> |
| | | /// <returns></returns> |
| | | public static (bool, string, object?) ValidateModelData<T>(List<T> datas) where T : class, new() |
| | | { |
| | | Type modelType = typeof(T); |
| | |
| | | Type[] types = propertyInfo.PropertyType.GenericTypeArguments; |
| | | if (types.Length == 1) |
| | | { |
| | | string str = value.Serialize(); |
| | | if (str == "[]") |
| | | if (tempValue.ChangeType(property.PropertyType).ToString() == propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1].ChangeType(property.PropertyType).ToString()) |
| | | { |
| | | return (false, $"ã{property.Name}ã屿§çå¼ä¸ºã{propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1]}ãæ¶ã{propertyInfo.Name}ã屿§çå¼ä¸å¯ä¸ºç©º", data); |
| | | string str = value.Serialize(); |
| | | if (str == "[]") |
| | | { |
| | | return (false, $"ã{property.Name}ã屿§çå¼ä¸ºã{propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1]}ãæ¶ã{propertyInfo.Name}ã屿§çå¼ä¸å¯ä¸ºç©º", data); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else if (types.Length == 0) |
| | | { |
| | | if (tempValue.ChangeType(property.PropertyType) != propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1].ChangeType(property.PropertyType) && value == null && string.IsNullOrEmpty(value.ToString())) |
| | | if (tempValue.ChangeType(property.PropertyType).ToString() == propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1].ChangeType(property.PropertyType).ToString() && value == null && string.IsNullOrEmpty(value.ToString())) |
| | | { |
| | | return (false, $"ã{property.Name}ã屿§çå¼ä¸ºã{propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1]}ãæ¶ã{propertyInfo.Name}ã屿§çå¼ä¸å¯ä¸ºç©º", data); |
| | | } |