You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to re-use the already existing attributes on my DTO's to create validation rules.
I've tried something on this Gist but I think it's not going to work because the compiler can't infer the property type from the expression. The not working part is commented out.
Any ideas? Or is there already something implemented to do this?
The text was updated successfully, but these errors were encountered:
You'd have to do it by constructing PropertyRule instances directly rather than trying to use expressions. Although FV's public api is strongly typed, internally it isn't so you can drop down to the internal api.
Take a look at the code for how RuleFor is defined...it creates a RuleBuilder and from that create PropertyRule from the expression, and then uses AddRule to store this in the validator. You'd need to do something similar.
I'm trying to re-use the already existing attributes on my DTO's to create validation rules.
I've tried something on this Gist but I think it's not going to work because the compiler can't infer the property type from the expression. The not working part is commented out.
Any ideas? Or is there already something implemented to do this?
The text was updated successfully, but these errors were encountered: