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

Add support for single validation error with Result.Invalid #144

Merged
merged 3 commits into from
Aug 29, 2023

Conversation

IliyanAng
Copy link
Contributor

More often than not I find myself passing a single Validation error in the Result.Invalid method. This PR addresses that.
I do believe this to be a needed improvement, as it's very annoying to create new Lists only to pass a single object in them.

  • Support for single validation error in the Result.Invalid method
  • Added unit tests to validate behavior
  • All existing behavior remains the same. The single instance of the Validation Error will be passed in a new List upon Result.Invalid creation
     //This instantiates a new list with the single validation error in it
     public new static Result Invalid(ValidationError validationError)
        {
            return new Result(ResultStatus.Invalid) { ValidationErrors = { validationError } };
        }

- Support for single validation error in the Result.Invalid method
- Added unit tests to test the behavior
@ardalis
Copy link
Owner

ardalis commented Aug 29, 2023

Love it and agree, thanks!

@ardalis ardalis merged commit 31464ea into ardalis:main Aug 29, 2023
1 check passed
@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
Ardalis.Result.FluentValidation 86% 50% 6
Ardalis.Result.Sample.Core 18% 18% 63
Ardalis.Result 23% 7% 73
Summary 24% (93 / 387) 19% (10 / 54) 142

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 this pull request may close these issues.

2 participants