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

Refactored validation part #152

Merged
merged 2 commits into from
Dec 17, 2017
Merged

Refactored validation part #152

merged 2 commits into from
Dec 17, 2017

Conversation

GooRiOn
Copy link
Member

@GooRiOn GooRiOn commented Dec 13, 2017

Info

This Pull Request is related to issue no. #150

With some hard time for figuring out how to make it better but I did it :D !

Changes

  • Created ValitRuleExtensions class with VallidateRules() extension
  • Changed validation part in IValitRules<TObject>
  • Changed validation part in CollectionValitRule
  • Changed validation part in NestedObjectCollectionValitRul

@codecov
Copy link

codecov bot commented Dec 13, 2017

Codecov Report

Merging #152 into develop will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           develop   #152   +/-   ##
======================================
  Coverage      100%   100%           
======================================
  Files           38     39    +1     
  Lines          784    763   -21     
======================================
- Hits           784    763   -21
Impacted Files Coverage Δ
src/Valit/Rules/NestedObjectCollectionValitRule.cs 100% <100%> (ø) ⬆️
src/Valit/ValitRules.cs 100% <100%> (ø) ⬆️
src/Valit/Rules/ValitRuleExtensions.cs 100% <100%> (ø)
src/Valit/Rules/CollectionValitRule.cs 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca9b5e6...3ad7ff2. Read the comment docs.

Copy link
Collaborator

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Less and cleaner code with all the tests passing 🎉
Just 2 suggestions (which doesn't have to be done)

{
rules.ThrowIfNull();

var result = ValitResult.Success;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an enum to me, maybe it would be clearer to do new ValitResult()?

Copy link
Member Author

@GooRiOn GooRiOn Dec 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can always hover on var so it's clear that's IValitStrategy object :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True 😄


if(!result.Succeeded)
{
strategy.Fail(rule, result, out bool cancel);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I said this a couple of days ago, but maybe lets make strategy.Fail return a bool?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arekbal did this as an out param. I think he's the right person to ask why we actualy use it :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaner API when implementing that method. Instead of guessing or going through some docs to find why method returns bool and what it means(true for cancel or continue?), one just implements a method with clear declaration.

Copy link
Collaborator

@paw3lx paw3lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me too 👍 the best refactoring! :) Less code and looks clean.

@GooRiOn GooRiOn merged commit f7cac04 into develop Dec 17, 2017
@GooRiOn GooRiOn deleted the feature/150 branch December 17, 2017 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants