title: Set property is rule is valid with FluentValidation
body: <p>I have a validator that looks like this</p>
  
  <pre><code>public class ImageValidator : AbstractValidator&lt;Image&gt;
  {
      public ImageValidator()
      {
          RuleFor(e =&gt; e.Name).NotEmpty().Length(1, 255).WithMessage("Name must be between 1 and 255 chars");
  
          RuleFor(e =&gt; e.Data).NotNull().WithMessage("Image must have data").When(e =&gt; e.Id == 0);
  
          RuleFor(e =&gt; e.Height).GreaterThan(0).WithMessage("Image must have a height");
  
          RuleFor(e =&gt; e.Width).GreaterThan(0).WithMessage("Image must have a width");
      }
  }
  </code></pre>
  
  <p>Now my unit tests are failing because Height and Width are populated based on the value in Data.</p>
  
  <p>Data holds a byte array which creates a bitmap image.  If Data is not null (and Id equals 0, so its a new image), i can create a Bitmap image and obtain the Height and Width values.  Upon updating, the Height and Width would already be populated and Data could be null, because it would be stored in the database already.</p>
  
  <p>Is there anyway i can populate the values of Height and Width if the validation rule for Data is true within my validator?</p>
  
  <p>Before i had a check like</p>
  
  <pre><code>if (myObject.Data == null) throw new ApplicationException(...
  </code></pre>
  
  <p>But i think this is a validation rule, and should be in the validator, or do i just need to split the rules up?</p>