DD.WellWorkover.Cloud/AsbCloudApp/Data/ValidationResultDto.cs

27 lines
659 B
C#
Raw Normal View History

2023-12-04 17:09:58 +05:00
using System.Collections.Generic;
2023-12-13 18:06:48 +05:00
using System.ComponentModel.DataAnnotations;
using System.Linq;
2023-12-04 17:09:58 +05:00
2023-12-13 18:06:48 +05:00
namespace AsbCloudApp.Data;
2023-12-04 17:09:58 +05:00
/// <summary>
/// Результат валидации объекта
/// </summary>
public class ValidationResultDto<T>
where T : class
{
/// <summary>
/// Флаг валидности
/// </summary>
2023-12-13 18:06:48 +05:00
public bool IsValid => !Warnings.Any();
2023-12-04 17:09:58 +05:00
/// <summary>
/// Объект валидации
/// </summary>
public virtual T Item { get; set; } = null!;
2023-12-04 17:09:58 +05:00
/// <summary>
/// Предупреждения
/// </summary>
2023-12-13 18:06:48 +05:00
public IEnumerable<ValidationResult> Warnings { get; set; } = Enumerable.Empty<ValidationResult>();
2023-12-04 17:09:58 +05:00
}