Skip to content

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
@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