using System;
using System.Collections.Generic;
using System.IO.Abstractions;
using StellaOps.Excititor.Connectors.Abstractions;

namespace StellaOps.Excititor.Connectors.Oracle.CSAF.Configuration;

public sealed class OracleConnectorOptionsValidator : IVexConnectorOptionsValidator<OracleConnectorOptions>
{
    private readonly IFileSystem _fileSystem;

    public OracleConnectorOptionsValidator(IFileSystem fileSystem)
    {
        _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
    }

    public void Validate(VexConnectorDescriptor descriptor, OracleConnectorOptions options, IList<string> errors)
    {
        ArgumentNullException.ThrowIfNull(descriptor);
        ArgumentNullException.ThrowIfNull(options);
        ArgumentNullException.ThrowIfNull(errors);

        try
        {
            options.Validate(_fileSystem);
        }
        catch (Exception ex)
        {
            errors.Add(ex.Message);
        }
    }
}
