using System.Text.RegularExpressions;

public abstract class UriBasedSongValidatorBase : SongValidatorBase
{
    public abstract string UriValidatorRegex { get; }

    public UriBasedSongValidatorBase(ILogger logger, SpotifyApiClient spotifyApiClient) : base(logger, spotifyApiClient)
    { }

    public Match GetUriMatch(Uri songUri)
    {
        var regexp = new Regex(UriValidatorRegex, RegexOptions.IgnoreCase);
        return regexp.Match(songUri.ToString());
    }

    public override async Task<bool> CanValidateUriAsync(Uri songUri)
    {
        var result = await Task.Run(() =>
        {
            return GetUriMatch(songUri).Success;
        });
        return result;
    }
}