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 property resolver for include properties #2003

Merged
merged 3 commits into from Sep 11, 2022

Conversation

sergeivalko
Copy link
Contributor

@sergeivalko sergeivalko commented Sep 7, 2022

Fix

This pull request fixes how the resolver works with IncludeProperties.
For example we have property resolver camelCase and when we are using
validator.Validate(new Person(), strategy => strategy.IncludeProperties(x=>x.Surname))
then validator will not validate our surname property cause our resolver resolve it as "surname"

IncludeProperties = "Surname" but resolver (RuleFor(x=>x.Surname)) = "surname" and it can't find the right property for validate

@sergeivalko
Copy link
Contributor Author

@JeremySkinner Have a look, please

@JeremySkinner
Copy link
Member

Hi @sergeivalko thanks for the suggestion.

Does this cause issues with including full chains inside the expression? Eg if you do IncludeProperties(x => x.Address.Line1), does this still work correctly? I think this might break that scenario (although I'm not sure if we have any tests for that at the moment).

@JeremySkinner
Copy link
Member

Ah, no, ignore my previous comment. I was misremembering how PropertyNameResolver worked. I think this should be fine - I'll try and do a bit more testing on it later this week and will then try and do a release, probably on Friday.

@sergeivalko
Copy link
Contributor Author

sergeivalko commented Sep 7, 2022

@JeremySkinner yes everything is working fine I've just checked so looking forward to feedback, thanks.
i've added tests for your case

@sergeivalko
Copy link
Contributor Author

@JeremySkinner any updates?

@JeremySkinner
Copy link
Member

No, I haven't had time to look at this any further. I only work on FluentValidation in my spare time, and real-life takes priority. Please be patient and I'll try and get to it as quickly as I can.

@sergeivalko
Copy link
Contributor Author

thank you

Copy link
Member

@JeremySkinner JeremySkinner left a comment

Choose a reason for hiding this comment

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

Thanks for doing this.

The MemberFromExpression can be simplified as the chain variable is no longer needed. If you could make that change then I'll get this merged. Thanks!

@JeremySkinner JeremySkinner merged commit 29b99ec into FluentValidation:main Sep 11, 2022
@JeremySkinner JeremySkinner added this to the 11.2.2 milestone Sep 11, 2022
@JeremySkinner
Copy link
Member

I've pushed out 11.2.2 with this change

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.

None yet

2 participants