<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>FluentValidation Issue Tracker Rss Feed</title><link>http://www.codeplex.com/FluentValidation/WorkItem/List.aspx</link><description>FluentValidation Issue Tracker Rss Description</description><item><title>Commented Unassigned: How to validate the condition on dropdownloistfor in mvc razor [7144]</title><link>http://fluentvalidation.codeplex.com/workitem/7144</link><description>hi everybody,&lt;br /&gt;&lt;br /&gt;int genderid&amp;#59;&lt;br /&gt;selectlist genders&amp;#59;&lt;br /&gt;&lt;br /&gt;html.dropdownlistfor &amp;#40; genderid ,genders&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;these are my three values in  my drop down that i am unable to validate with fluent validation.&lt;br /&gt;&lt;br /&gt;0 select&lt;br /&gt;1 male &lt;br /&gt;2 female &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;so can you please suggest me how to handle it.&lt;br /&gt;Comments: Please could you provide more information - I&amp;#39;m going to need more than that to go on if you&amp;#39;d like me to help. What do you mean when you say that the values are &amp;#34;unable to validate&amp;#34;&amp;#63; Are you getting an error&amp;#63; How have you defined your validator&amp;#63;</description><author>JeremyS</author><pubDate>Fri, 10 May 2013 14:16:33 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: How to validate the condition on dropdownloistfor in mvc razor [7144] 20130510021633P</guid></item><item><title>Created Unassigned: How to validate the condition on dropdownloistfor in mvc razor [7144]</title><link>http://fluentvalidation.codeplex.com/workitem/7144</link><description>hi everybody,&lt;br /&gt;&lt;br /&gt;int genderid&amp;#59;&lt;br /&gt;selectlist genders&amp;#59;&lt;br /&gt;&lt;br /&gt;html.dropdownlistfor &amp;#40; genderid ,genders&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;these are my three values in  my drop down that i am unable to validate with fluent validation.&lt;br /&gt;&lt;br /&gt;0 select&lt;br /&gt;1 male &lt;br /&gt;2 female &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;so can you please suggest me how to handle it.&lt;br /&gt;</description><author>Anubhava</author><pubDate>Fri, 10 May 2013 11:46:18 GMT</pubDate><guid isPermaLink="false">Created Unassigned: How to validate the condition on dropdownloistfor in mvc razor [7144] 20130510114618A</guid></item><item><title>Edited Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basically I want to be able to have a ruleset which specifies  the length not to be 1 to 140 but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description><author>bobduncan</author><pubDate>Wed, 08 May 2013 09:47:24 GMT</pubDate><guid isPermaLink="false">Edited Unassigned: ValidatorType Replace- RemoveRule [7143] 20130508094724A</guid></item><item><title>Commented Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Comments: Even though it isn&amp;#39;t exactly what I was hoping for, it will be enough to solve my problem.&amp;#10;Thank you for providing me with a solution.</description><author>bobduncan</author><pubDate>Wed, 08 May 2013 09:46:48 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: ValidatorType Replace- RemoveRule [7143] 20130508094648A</guid></item><item><title>Commented Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Comments: You wouldn&amp;#39;t get two rules executed if you include them in separate rulesets, then explicitly choose which one you want to execute. See the documentation on named rulesets&amp;#58; https&amp;#58;&amp;#47;&amp;#47;fluentvalidation.codeplex.com&amp;#47;wikipage&amp;#63;title&amp;#61;CreatingAValidator&amp;#38;referringTitle&amp;#61;Documentation&amp;#38;ANCHOR&amp;#35;RuleSets</description><author>JeremyS</author><pubDate>Wed, 08 May 2013 08:30:14 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: ValidatorType Replace- RemoveRule [7143] 20130508083014A</guid></item><item><title>Commented Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Comments: That would mean I would get two validation errors when I have an input string where it&amp;#39;s length would be  &amp;#60;70, while only the latest rule should be applied and the other one be ignored.&amp;#10;&amp;#10;Even though RemoveRule is used for a one-off modification, is there no other way to accomplice what I want to achieve&amp;#63;</description><author>bobduncan</author><pubDate>Wed, 08 May 2013 07:57:05 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: ValidatorType Replace- RemoveRule [7143] 20130508075705A</guid></item><item><title>Commented Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Comments: Yes, so this is the correct behaviour - validator definitions are all built once when the validator is instantiated - you can&amp;#39;t embed something like RemoveRule inside the validator&amp;#39;s constructor as it will fire immediately as soon as the validator is instantiated. &amp;#10;&amp;#10;RemoveRule is used for a one-off modification of the rules after the validator has been instantiated. &amp;#10;&amp;#10;In your situation, it&amp;#39;d be better to define the rule twice in different rulesets rather than trying to use RemoveRule for this.&amp;#10;&amp;#10;Jeremy</description><author>JeremyS</author><pubDate>Tue, 07 May 2013 12:54:08 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: ValidatorType Replace- RemoveRule [7143] 20130507125408P</guid></item><item><title>Commented Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Comments: Yes thank you. However my problem still remains, since the replacerule gets executed in the constructor instead of at validation time when the ruleset is used.</description><author>bobduncan</author><pubDate>Tue, 07 May 2013 11:43:13 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: ValidatorType Replace- RemoveRule [7143] 20130507114313A</guid></item><item><title>Commented Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Comments: When you use the When or Unless methods, the real validator is wrapped in an instance of DelegatingValidator, so you&amp;#39;ll need to use typeof&amp;#40;DelegatingValidator&amp;#41; instead</description><author>JeremyS</author><pubDate>Tue, 07 May 2013 09:06:40 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: ValidatorType Replace- RemoveRule [7143] 20130507090640A</guid></item><item><title>Created Unassigned: ValidatorType Replace- RemoveRule [7143]</title><link>http://fluentvalidation.codeplex.com/workitem/7143</link><description>What type is the following validator&amp;#58;&lt;br /&gt;&lt;br /&gt;RuleFor&amp;#40;x &amp;#61;&amp;#62; x.Surname&amp;#41;.Length&amp;#40;1, 140&amp;#41;.Unless&amp;#40;MyUnlessMethod&amp;#41;&amp;#59;&lt;br /&gt;&lt;br /&gt;The Replace&amp;#47;RemoveRule methods needs a type, but when I supply it with typeof&amp;#40;LengthValidator&amp;#41; it doesn&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;Basicly I want to be able to have a ruleset which specifies  the length not to be 1 to 140but 1 to 70.&lt;br /&gt;But in both cases and I need to be able to ignore the rule when the Unless case is met.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description><author>bobduncan</author><pubDate>Mon, 06 May 2013 09:11:07 GMT</pubDate><guid isPermaLink="false">Created Unassigned: ValidatorType Replace- RemoveRule [7143] 20130506091107A</guid></item><item><title>Commented Issue: Make inheritance of FluentValidationModelValidatorProvider useful [7134]</title><link>http://fluentvalidation.codeplex.com/workitem/7134</link><description>Hi Jeremy,&lt;br /&gt;&lt;br /&gt;The FluentValidationModelValidatorProvider integration with MVC is very useful. However, if one would like to override some parts of the class it is not possible since the only overridable function is GetValidators.&lt;br /&gt;&lt;br /&gt;In particular, it would be interesting to be able to access the &amp;#40;currently&amp;#41; private method IsValidatingProperty and create a new method that invokes the validator factory, which can be overriden.&lt;br /&gt;&lt;br /&gt;Rationale&amp;#58; The type passed to the validator factory may not be always correct in order to make the best decision for a validator. In other words, ModelMetadata.ContainerType or ModelMetadata.ModelType &amp;#40;depending on wether a property or the model is being validated&amp;#41; may not be the correct type to use.&lt;br /&gt;&lt;br /&gt;For example, suppose the following form models&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;class F1 &amp;#123; &lt;br /&gt;    int Property &amp;#123;get&amp;#59; set&amp;#59;&amp;#125;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;class F2 &amp;#58; F1 &amp;#123;&lt;br /&gt;   int Another &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;&amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Each with its own validator. Now suppose I have a partial view that renders the appropriate way to select Property &amp;#40;involving a &amp;#96;TextBoxFor&amp;#40;f &amp;#61;&amp;#62; f.Property&amp;#41;&amp;#96;, and it is strongly typed to F1. This partial will be called from a strongly typed view of F2.&lt;br /&gt;&lt;br /&gt;In this scenario, when the &amp;#96;TextBoxFor&amp;#40;f &amp;#61;&amp;#62; f.Property&amp;#41;&amp;#96; is rendered, the ModelMetadata.ContainerType will be F1 instead of F2, thus rendering the wrong unobtrusive validations.&lt;br /&gt;&lt;br /&gt;Summary&amp;#58; an overridable function that determines which type to pass to the validator factory would be nice to have in the Provider.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following code should provide everything needed.&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;public virtual IValidator InvokeValidatorFactory&amp;#40;ModelMetadata metadata,&lt;br /&gt;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9; ControllerContext context&amp;#41; &amp;#123;&lt;br /&gt;&amp;#9;if &amp;#40;IsValidatingProperty&amp;#40;metadata&amp;#41;&amp;#41; &amp;#123;&lt;br /&gt;&amp;#9;&amp;#9;return ValidatorFactory.GetValidator&amp;#40;metadata.ContainerType&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;&amp;#125;&lt;br /&gt;&amp;#9;return ValidatorFactory.GetValidator&amp;#40;metadata.ModelType&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;public override IEnumerable&amp;#60;ModelValidator&amp;#62; GetValidators&amp;#40;ModelMetadata metadata, &lt;br /&gt;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;ControllerContext context&amp;#41; &amp;#123;&lt;br /&gt;&amp;#9;IValidator validator &amp;#61; InvokeValidatorFactory&amp;#40;metadata, context&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;if &amp;#40;IsValidatingProperty&amp;#40;metadata&amp;#41;&amp;#41; &amp;#123;&lt;br /&gt;&amp;#9;&amp;#9;return GetValidatorsForProperty&amp;#40;metadata, context, validator&amp;#41;&amp;#59;&lt;br /&gt;&amp;#9;&amp;#125;&lt;br /&gt;&amp;#9;return GetValidatorsForModel&amp;#40;metadata, context, validator&amp;#41;&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;Comments: Just for the record, the current FluentValidation 4.0 fixes this problem for me.&amp;#10;&amp;#10;Thanks for your work in this&amp;#33;</description><author>fsateler</author><pubDate>Mon, 29 Apr 2013 23:19:27 GMT</pubDate><guid isPermaLink="false">Commented Issue: Make inheritance of FluentValidationModelValidatorProvider useful [7134] 20130429111927P</guid></item><item><title>Closed Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;</description><author>JeremyS</author><pubDate>Mon, 29 Apr 2013 12:43:06 GMT</pubDate><guid isPermaLink="false">Closed Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429124306P</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: Thanks.&amp;#10;&amp;#10;This is out-of-scope for FluentValidation itself - it&amp;#39;s more to do with how you interact with the IoC container than FluentValidation. I&amp;#39;ll leave it here in case other people find it useful, but isn&amp;#39;t something that will be included in FluentValidation itself</description><author>JeremyS</author><pubDate>Mon, 29 Apr 2013 12:43:00 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429124300P</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: sorry for above but I did not know that&amp;#39;s how it works.</description><author>wojtpl2</author><pubDate>Mon, 29 Apr 2013 12:09:09 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429120909P</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: &amp;#96;&amp;#96;&amp;#96;&amp;#10;   public class NotAssemblyScanner &amp;#58; Attribute &amp;#123;&amp;#10;        &amp;#10;    &amp;#125;&amp;#10;&amp;#96;&amp;#96;&amp;#96;&amp;#10;&amp;#10;in AssemblyScanner&amp;#58;&amp;#10;&amp;#10;&amp;#96;&amp;#96;&amp;#96;&amp;#10;&amp;#9;&amp;#9;private IEnumerable&amp;#60;AssemblyScanResult&amp;#62; Execute&amp;#40;&amp;#41; &amp;#123;&amp;#10;&amp;#9;&amp;#9;&amp;#9;var openGenericType &amp;#61; typeof&amp;#40;IValidator&amp;#60;&amp;#62;&amp;#41;&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#9;var query &amp;#61; from type in types&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;let interfaces &amp;#61; type.GetInterfaces&amp;#40;&amp;#41;&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;let genericInterfaces &amp;#61; interfaces.Where&amp;#40;i &amp;#61;&amp;#62; i.IsGenericType &amp;#38;&amp;#38; i.GetGenericTypeDefinition&amp;#40;&amp;#41; &amp;#61;&amp;#61; openGenericType&amp;#41;&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;let matchingInterface &amp;#61; genericInterfaces.FirstOrDefault&amp;#40;&amp;#41;&amp;#10;                        where matchingInterface &amp;#33;&amp;#61; null __&amp;#38;&amp;#38; &amp;#33;type.GetCustomAttributes&amp;#40;typeof&amp;#40;NotAssemblyScanner&amp;#41;, false&amp;#41;.Any&amp;#40;&amp;#41;__&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;select new AssemblyScanResult&amp;#40;matchingInterface, type&amp;#41;&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#9;return query&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;&amp;#96;&amp;#96;&amp;#96;&amp;#10;&amp;#10;in AssenblyScannerTest&amp;#58;&amp;#10;&amp;#10;&amp;#35;region License&amp;#10;&amp;#47;&amp;#47; Copyright &amp;#40;c&amp;#41; Jeremy Skinner &amp;#40;http&amp;#58;&amp;#47;&amp;#47;www.jeremyskinner.co.uk&amp;#41;&amp;#10;&amp;#47;&amp;#47; &amp;#10;&amp;#47;&amp;#47; Licensed under the Apache License, Version 2.0 &amp;#40;the &amp;#34;License&amp;#34;&amp;#41;&amp;#59; &amp;#10;&amp;#47;&amp;#47; you may not use this file except in compliance with the License. &amp;#10;&amp;#47;&amp;#47; You may obtain a copy of the License at &amp;#10;&amp;#47;&amp;#47; &amp;#10;&amp;#47;&amp;#47; http&amp;#58;&amp;#47;&amp;#47;www.apache.org&amp;#47;licenses&amp;#47;LICENSE-2.0&amp;#10;&amp;#47;&amp;#47; &amp;#10;&amp;#47;&amp;#47; Unless required by applicable law or agreed to in writing, software &amp;#10;&amp;#47;&amp;#47; distributed under the License is distributed on an &amp;#34;AS IS&amp;#34; BASIS, &amp;#10;&amp;#47;&amp;#47; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. &amp;#10;&amp;#47;&amp;#47; See the License for the specific language governing permissions and &amp;#10;&amp;#47;&amp;#47; limitations under the License.&amp;#10;&amp;#47;&amp;#47; &amp;#10;&amp;#47;&amp;#47; The latest version of this file can be found at http&amp;#58;&amp;#47;&amp;#47;www.codeplex.com&amp;#47;FluentValidation&amp;#10;&amp;#35;endregion&amp;#10;&amp;#10;namespace FluentValidation.Tests &amp;#123;&amp;#10;&amp;#9;using System.Collections.Generic&amp;#59;&amp;#10;&amp;#9;using System.Linq&amp;#59;&amp;#10;&amp;#9;using NUnit.Framework&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#91;TestFixture&amp;#93;&amp;#10;&amp;#9;public class AssemblyScannerTester &amp;#123;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#91;Test&amp;#93;&amp;#10;&amp;#9;&amp;#9;public void Finds_validators_for_types&amp;#40;&amp;#41; &amp;#123;&amp;#10;            var scanner &amp;#61; new AssemblyScanner&amp;#40;new&amp;#91;&amp;#93; &amp;#123; typeof&amp;#40;Model1Validator&amp;#41;, typeof&amp;#40;Model2Validator&amp;#41;__, typeof&amp;#40;Model3Validator&amp;#41;__ &amp;#125;&amp;#41;&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#9;var results &amp;#61; scanner.ToList&amp;#40;&amp;#41;&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#9;results&amp;#91;0&amp;#93;.ValidatorType.ShouldEqual&amp;#40;typeof&amp;#40;Model1Validator&amp;#41;&amp;#41;&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#9;results&amp;#91;0&amp;#93;.InterfaceType.ShouldEqual&amp;#40;typeof&amp;#40;IValidator&amp;#60;Model1&amp;#62;&amp;#41;&amp;#41;&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#9;results&amp;#91;1&amp;#93;.ValidatorType.ShouldEqual&amp;#40;typeof&amp;#40;Model2Validator&amp;#41;&amp;#41;&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#9;results&amp;#91;1&amp;#93;.InterfaceType.ShouldEqual&amp;#40;typeof&amp;#40;IValidator&amp;#60;Model2&amp;#62;&amp;#41;&amp;#41;&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#9; __   results.Count.ShouldEqual&amp;#40;2&amp;#41;&amp;#59;__&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#91;Test&amp;#93;&amp;#10;&amp;#9;&amp;#9;public void ForEach_iterates_over_types&amp;#40;&amp;#41; &amp;#123;&amp;#10;            var scanner &amp;#61; new AssemblyScanner&amp;#40;new&amp;#91;&amp;#93; &amp;#123; typeof&amp;#40;Model1Validator&amp;#41;, typeof&amp;#40;Model2Validator&amp;#41;__, typeof&amp;#40;Model3Validator&amp;#41;__ &amp;#125;&amp;#41;&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#9;var results &amp;#61; new List&amp;#60;AssemblyScanner.AssemblyScanResult&amp;#62;&amp;#40;&amp;#41;&amp;#59;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#9;scanner.ForEach&amp;#40;x &amp;#61;&amp;#62; results.Add&amp;#40;x&amp;#41;&amp;#41;&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#9;results.Count.ShouldEqual&amp;#40;2&amp;#41;&amp;#59;&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;&amp;#10;&amp;#9;&amp;#9;public class Model1 &amp;#123;&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;&amp;#10;&amp;#9;&amp;#9;public class Model2 &amp;#123;&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;&amp;#10; __       public class Model3&amp;#10;        &amp;#123;&amp;#10;&amp;#10;        &amp;#125;&amp;#10;&amp;#10;&amp;#9;&amp;#9;public class Model1Validator&amp;#58;AbstractValidator&amp;#60;Model1&amp;#62; &amp;#123;&amp;#10;&amp;#9;&amp;#9;&amp;#9;&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;        &amp;#10;&amp;#9;&amp;#9;public class Model2Validator&amp;#58;AbstractValidator&amp;#60;Model2&amp;#62; &amp;#123;&amp;#10;&amp;#10;&amp;#9;&amp;#9;&amp;#125;&amp;#10;&amp;#10;        &amp;#91;NotAssemblyScanner&amp;#93;&amp;#10;        public class Model3Validator &amp;#58; AbstractValidator&amp;#60;Model2&amp;#62;&amp;#10;        &amp;#123;&amp;#10;&amp;#10;        &amp;#125;&amp;#10;&amp;#9;&amp;#125;__&amp;#10;&amp;#10;&amp;#125;&amp;#10;</description><author>wojtpl2</author><pubDate>Mon, 29 Apr 2013 12:04:08 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429120408P</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: ok. Maybe can you add something like &amp;#91;NotAssemblyScaner&amp;#93; attribute&amp;#63;&amp;#10;</description><author>wojtpl2</author><pubDate>Mon, 29 Apr 2013 11:49:32 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429114932A</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: If you&amp;#39;re using an IoC container, rather than relying on auto-registration I&amp;#39;d suggest that you explicitly register only those validators that you require to be automatically validated &amp;#40;ie the top-level validators&amp;#41;.</description><author>JeremyS</author><pubDate>Mon, 29 Apr 2013 10:41:08 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429104108A</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: Thanks for your help.&amp;#10;&amp;#10;But in my project I have Validator Factory with an Inversion of Control Container. I haven&amp;#39;t manual add &amp;#91;Validator&amp;#93; attribute. In this case, can&amp;#39;t be done so easily. But I have idea what to do.&amp;#10;&amp;#10;I use AutoFrac.&amp;#10;&amp;#96;&amp;#96;&amp;#96;&amp;#10;public class AutoFacValidatorFactory &amp;#58; IValidatorFactory&amp;#10;    &amp;#123;&amp;#10;        private readonly IComponentContext _container&amp;#59;&amp;#10;&amp;#10;        public AutoFacValidatorFactory&amp;#40;IComponentContext provider&amp;#41;&amp;#10;        &amp;#123;&amp;#10;            _container &amp;#61; provider&amp;#59;&amp;#10;        &amp;#125;&amp;#10;&amp;#10;        public IValidator&amp;#60;T&amp;#62; GetValidator&amp;#60;T&amp;#62;&amp;#40;&amp;#41;&amp;#10;        &amp;#123;&amp;#10;            return &amp;#40;IValidator&amp;#60;T&amp;#62;&amp;#41;GetValidator&amp;#40;typeof&amp;#40;T&amp;#41;&amp;#41;&amp;#59;&amp;#10;        &amp;#125;&amp;#10;&amp;#10;        public IValidator GetValidator&amp;#40;Type type&amp;#41;&amp;#10;        &amp;#123;&amp;#10;            var genericType &amp;#61; typeof&amp;#40;IValidator&amp;#60;&amp;#62;&amp;#41;.MakeGenericType&amp;#40;type&amp;#41;&amp;#59;&amp;#10;            object validator&amp;#59;&amp;#10;            if &amp;#40;_container.TryResolve&amp;#40;genericType, out validator&amp;#41;&amp;#41;&amp;#10;                return &amp;#40;IValidator&amp;#41;validator&amp;#59;&amp;#10;            return null&amp;#59;&amp;#10;        &amp;#125;&amp;#10;    &amp;#125;&amp;#10;    public static class FluentValidationConfig&amp;#10;    &amp;#123;&amp;#10;        public static void BootstrapFluentValidation&amp;#40;&amp;#41;&amp;#10;        &amp;#123;&amp;#10;            var builder &amp;#61; new ContainerBuilder&amp;#40;&amp;#41;&amp;#59;&amp;#10;            builder.RegisterType&amp;#60;AutoFacValidatorFactory&amp;#62;&amp;#40;&amp;#41;.As&amp;#60;IValidatorFactory&amp;#62;&amp;#40;&amp;#41;.SingleInstance&amp;#40;&amp;#41;&amp;#59;&amp;#10;            AssemblyScanner.FindValidatorsInAssembly&amp;#40;typeof &amp;#40;PojazdModelValidator&amp;#41;.Assembly&amp;#41;&amp;#10;                           .ForEach&amp;#40;result &amp;#61;&amp;#62; builder.RegisterType&amp;#40;result.ValidatorType&amp;#41;.As&amp;#40;result.InterfaceType&amp;#41;.SingleInstance&amp;#40;&amp;#41;&amp;#41;&amp;#59; &amp;#10;&amp;#10;            var container &amp;#61; builder.Build&amp;#40;&amp;#41;&amp;#59;&amp;#10;            ModelValidatorProviders.Providers.Add&amp;#40;new FluentValidationModelValidatorProvider&amp;#40;container.Resolve&amp;#60;IValidatorFactory&amp;#62;&amp;#40;&amp;#41;&amp;#41;&amp;#41;&amp;#59;&amp;#10;            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes &amp;#61; false&amp;#59;&amp;#10;        &amp;#125;&amp;#10;    &amp;#125;&amp;#10;&amp;#96;&amp;#96;&amp;#96;&amp;#10;</description><author>wojtpl2</author><pubDate>Mon, 29 Apr 2013 10:21:55 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429102155A</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: Hi&amp;#10;&amp;#10;So the issue here is that you&amp;#39;re using the &amp;#91;Validator&amp;#93; attribute incorrectly.&amp;#10;&amp;#10;In your code, you&amp;#39;re using both SetValidator and the ValidatorAttribute, which will cause each Address property to be validated twice.&amp;#10;&amp;#10;When you use the &amp;#91;Validator&amp;#93; attribute, this tells MVC to instantiate an AddressValidator &amp;#42;every time it encouters a property of type Address&amp;#42;. In your case, this &amp;#42;isn&amp;#39;t&amp;#42; what you want, because you&amp;#39;re also explicitly defining the AddressValidator in the SetValidator call. So MVC executes validation for each Address property twice&amp;#58;&amp;#10;&amp;#10;- When MVC&amp;#39;s model binding process encouters the Address property, it will create an execute an AddressValidator, completely independently of the PersonValidator &amp;#40;so the .When clause is completely ignored, as the PersonValidator hasn&amp;#39;t event been invoked yet&amp;#41;&amp;#10;- MVC will then ask FluentValidation to create and invoke the PersonValidator, which this time will take the When clause into account.&amp;#10;&amp;#10;Solution&amp;#58; Remove the &amp;#91;Validator&amp;#93; attribute from the Address class. You only want to put the attribute on the class that is the &amp;#42;top level&amp;#42; in the hierarchy, &amp;#40;in this case, Person&amp;#41;.&amp;#10;&amp;#10;</description><author>JeremyS</author><pubDate>Mon, 29 Apr 2013 09:07:45 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429090745A</guid></item><item><title>Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142]</title><link>http://fluentvalidation.codeplex.com/workitem/7142</link><description>I have models and validators&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&amp;#91;Validator&amp;#40;typeof&amp;#40;AdressValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Adress &amp;#123;&lt;br /&gt;        public string PostalCode &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public string Street &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    &amp;#91;Validator&amp;#40;typeof&amp;#40;PersonValidator&amp;#41;&amp;#41;&amp;#93;&lt;br /&gt;    public class Person&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public Adress Adress &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public bool IsAdress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;        public Adress Adress2 &amp;#123; get&amp;#59; set&amp;#59; &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class AdressValidator &amp;#58; AbstractValidator&amp;#60;Adress&amp;#62; &amp;#123;&lt;br /&gt;        public AdressValidator&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.PostalCode&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Street&amp;#41;.NotEmpty&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&lt;br /&gt;    public class PersonValidator &amp;#58; AbstractValidator&amp;#60;Person&amp;#62;&lt;br /&gt;    &amp;#123;&lt;br /&gt;        public PersonValidator&amp;#40;&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;&amp;#59;&lt;br /&gt;            RuleFor&amp;#40;p &amp;#61;&amp;#62; p.Adress2&amp;#41;.SetValidator&amp;#40;new AdressValidator&amp;#40;&amp;#41;&amp;#41;.When&amp;#40;p&amp;#61;&amp;#62;p.IsAdress2&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;And controlers&amp;#58;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt; public class HomeController &amp;#58; Controller&lt;br /&gt;    &amp;#123;&lt;br /&gt;        &amp;#47;&amp;#47;&lt;br /&gt;        &amp;#47;&amp;#47; GET&amp;#58; &amp;#47;Home&amp;#47;&lt;br /&gt;&lt;br /&gt;        public ActionResult Index&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            Person person &amp;#61; new Person&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                Adress &amp;#61; new Adress&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;                    PostalCode &amp;#61; &amp;#34;12-100&amp;#34;,&lt;br /&gt;                    Street &amp;#61; &amp;#34;Street 13&amp;#34;&lt;br /&gt;                &amp;#125;,&lt;br /&gt;                IsAdress2 &amp;#61; false,&lt;br /&gt;                Adress2 &amp;#61; new Adress&amp;#40;&amp;#41;&lt;br /&gt;            &amp;#125;&amp;#59;&lt;br /&gt;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        &amp;#91;HttpPost&amp;#93;&lt;br /&gt;        public ActionResult Index&amp;#40;Person person&amp;#41;&lt;br /&gt;        &amp;#123;&lt;br /&gt;            if &amp;#40;ModelState.IsValid&amp;#41; &amp;#123;&lt;br /&gt;                return RedirectToAction&amp;#40;&amp;#34;OK&amp;#34;&amp;#41;&amp;#59;&lt;br /&gt;            &amp;#125;&lt;br /&gt;            return View&amp;#40;person&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;&lt;br /&gt;        public ActionResult Ok&amp;#40;&amp;#41; &amp;#123;&lt;br /&gt;            return View&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;        &amp;#125;&lt;br /&gt;    &amp;#125;&lt;br /&gt;&amp;#96;&amp;#96;&amp;#96;&lt;br /&gt;&lt;br /&gt;Adress2 is always validated.&lt;br /&gt;&lt;br /&gt;In Attachments is solution without lib and packages.&lt;br /&gt;Comments: I have a workaround. If IsModel2 is false, you can not send variables from model2&amp;#58;&amp;#10;   var form &amp;#61; new FormCollection&amp;#40;&amp;#41; &amp;#123;&amp;#10;                &amp;#123;&amp;#34;Model.Name&amp;#34;, &amp;#34;Name&amp;#34;&amp;#125;, &amp;#10;                &amp;#123;&amp;#34;IsModel2&amp;#34;, &amp;#34;false&amp;#34;&amp;#125;&amp;#10;                &amp;#47;&amp;#42;,&amp;#123;&amp;#34;Model2.Name&amp;#34;, null&amp;#125;&amp;#42;&amp;#47;&amp;#10;            &amp;#125;&amp;#59;</description><author>wojtpl2</author><pubDate>Mon, 29 Apr 2013 06:37:37 GMT</pubDate><guid isPermaLink="false">Commented Unassigned: SetValidator with When not work valid in MVC 4 [7142] 20130429063737A</guid></item></channel></rss>