using Exam.Infrastructure.Validation.Constants;

namespace Exam.Infrastructure.Validation.Validation
{
    public interface IValidationErrors
    {

        IValidationErrors AddErrors(IEnumerable<ValidationErrorItem> errorItems);

        /// <summary>
        /// 添加领域驱动异常, 非捕获Exception引起的异常
        /// </summary>
        /// <param name="propertyName">引起异常的属性名称</param>
        /// <param name="errorMessage">具体异常信息</param>
        /// <param name="errorCode">异常代码</param>
        /// <param name="errorDescription">有关异常的详细描述或发生验证异常的字段描述</param>
        /// <param name="attemptedValue">试图用于描述异常信息的值</param>
        /// <returns></returns>
        IValidationErrors AddDomainError(string propertyName, string errorMessage, string errorCode = null, string errorDescription = null, object attemptedValue = null);

        /// <summary>
        /// 添加通用异常
        /// </summary>
        /// <param name="propertyName">引起异常的属性名称</param>
        /// <param name="errorMessage">具体异常信息</param>
        /// <param name="errorCode">异常代码</param>
        /// <param name="errorStackTrace">捕获异常堆栈信息</param>
        /// <param name="errorDescription">有关异常的详细描述或发生验证异常的字段描述</param>
        /// <param name="attemptedValue">试图用于描述异常信息的值</param>
        /// <returns></returns>
        /// <returns></returns>
        IValidationErrors AddError(string propertyName, string errorMessage, object attemptedValue, bool customState = false);

        /// <summary>
        /// 添加系统异常
        /// </summary>
        /// <param name="propertyName">默认为系统异常</param>
        /// <param name="errorMessage">系统错误</param>
        /// <param name="attemptedValue">试图用于描述异常信息的值</param>
        /// <returns></returns>
        IValidationErrors AddSystemError(string propertyName = InfrastructureConstant.SystemError, string errorMessage = InfrastructureConstant.SystemErrorDescription,
            object attemptedValue = null, bool customState = false);

        /// <summary>
        /// 结果是否正确
        /// </summary>
        bool IsValid { get; }

        IEnumerable<ValidationErrorItem> ErrorItems { get; }
    }
}
