using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using NodePipeline.Abstractions.Interfaces;
using NodePipeline.Abstractions.Interfaces.Validation;
using NodePipeline.Abstractions.Models.Validation;

namespace NodePipeline.Abstractions.Validators;

public abstract class NodeValidatorBase(IPipelineLocalizationProvider localizer) : INodeValidator
{
    protected readonly CultureInfo Culture = CultureInfo.CurrentCulture;
    protected readonly IPipelineLocalizationProvider Localizer = localizer;

    protected NodeValidationResult SuccessResult => new(ValidationResult.Valid,
        null,
        new ReadOnlyDictionary<string, List<NodeFieldValidationResult>>(
            new Dictionary<string, List<NodeFieldValidationResult>>()),
        new ReadOnlyDictionary<string, List<NodeFieldValidationResult>>(
            new Dictionary<string, List<NodeFieldValidationResult>>()));

    public abstract NodeValidationResult Validate(Dictionary<string, object> nodeFields,
        IReadOnlyDictionary<string, List<NodeFieldValidationResult>> fieldResults,
        Dictionary<string, List<NodeFieldValidationResult>> portResults);
}