Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.