Skip to content

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

Merged
ardalis merged 3 commits into
ardalis:mainfrom
IliyanAng:add-single-validation-error-support
Aug 29, 2023
Merged

Add support for single validation error with Result.Invalid#144
ardalis merged 3 commits into
ardalis:mainfrom
IliyanAng:add-single-validation-error-support

Conversation

@IliyanAng

Copy link
Copy Markdown
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

ardalis commented Aug 29, 2023

Copy link
Copy Markdown
Owner

Love it and agree, thanks!

Comment thread src/Ardalis.Result/Result.Void.cs Outdated
Comment thread src/Ardalis.Result/Result.cs Outdated
@ardalis ardalis merged commit 31464ea into ardalis:main Aug 29, 2023
@github-actions

Copy link
Copy Markdown

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