Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand FailIf #189

Open
virzak opened this issue Jun 23, 2023 · 0 comments · May be fixed by #213
Open

Expand FailIf #189

virzak opened this issue Jun 23, 2023 · 0 comments · May be fixed by #213

Comments

@virzak
Copy link

virzak commented Jun 23, 2023

I am using the following to fill functionality that's missing for my project. What are your thoughts on this and will you take a PR with similar functionality?

static class MyResult
{
    public static Result FailIf(bool isFailure, IEnumerable<IError> errors)
        => isFailure ? Result.Fail(errors) : Result.Ok();
    
    public static Result FailIfNotEmpty(IEnumerable<IError> errors)
        => errors.Any() ? Result.Fail(errors) : Result.Ok();

    public static Result FailIfNotEmpty<T>(IEnumerable<T> errors, Func<T, IError> func)
        => errors.Any() ? Result.Fail(errors.Select(error => func(error))) : Result.Ok();
}
@Kysluss Kysluss linked a pull request Jul 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant