@if (_errors.Any())
{
    <div class="messages-container">
        @foreach (var error in _errors)
        {
            <AlertMessageError Message="@error" />
        }
    </div>
}

@code {
    private readonly List<string> _errors = [];

    /// <summary>
    /// Adds a server validation error.
    /// </summary>
    public void AddError(string error)
    {
        _errors.Add(error);
        StateHasChanged();
    }

    /// <summary>
    /// Clears the server validation errors.
    /// </summary>
    public void Clear()
    {
        _errors.Clear();
        StateHasChanged();
    }
}
