namespace SharepointToolbox.Core.Models;

public class CsvValidationRow<T>
{
    public T? Record { get; }
    public bool IsValid => Errors.Count == 0;
    public List<string> Errors { get; }
    public string? RawRecord { get; }

    public CsvValidationRow(T record, List<string> errors)
    {
        Record = record;
        Errors = errors;
    }

    private CsvValidationRow(string rawRecord, string parseError)
    {
        Record = default;
        RawRecord = rawRecord;
        Errors = new List<string> { parseError };
    }

    public static CsvValidationRow<T> ParseError(string? rawRecord, string error)
        => new(rawRecord ?? string.Empty, error);
}
