using System.Collections.Generic;

namespace NcProgramManager.Cnc.Models
{
    public sealed class ValidationResult
    {
        public bool Success { get; }
        public IReadOnlyList<ValidationError> Errors { get; }

        private ValidationResult(bool success, IReadOnlyList<ValidationError> errors)
        {
            Success = success;
            Errors = errors ?? new ValidationError[0];
        }

        public static ValidationResult Ok()
        {
            return new ValidationResult(true, new ValidationError[0]);
        }

        public static ValidationResult Fail(IReadOnlyList<ValidationError> errors)
        {
            return new ValidationResult(false, errors);
        }

        /// <summary>Success result that still carries warning-level entries.</summary>
        public static ValidationResult OkWithWarnings(IReadOnlyList<ValidationError> warnings)
        {
            return new ValidationResult(true, warnings);
        }
    }
}
