How to use mvc dataannotations to validate property value if other property is set to true?
<p>I am trying to validate a form submit BUT i want to validate a property ONLY if another property is set to true.</p>

<p>my two properties:</p>

<pre><code>[DisplayName(Translations.Education.IsFeaturette)]
public  bool IsFeaturette { get; set; }

[DisplayName(Translations.Education.AddFeaturetteFor)]
[CusomValidatorForFeaturettes(IsFeaturette)]
public string[] Featurettes { get; set; }
</code></pre>

<p>custom annotation:</p>

<pre><code>public class CusomValidatorForFeaturettes: ValidationAttribute
{
    private readonly bool _IsFeatturette;
    public CusomValidatorForFeaturettes(bool isFeatturette): base("NOT OK")
    {
        _IsFeatturette = isFeatturette;
    }

    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        if (value == null &amp;&amp; _IsFeatturette )
        {
            var errorMessage = FormatErrorMessage(validationContext.DisplayName);
            return new ValidationResult(errorMessage);

        }
        return ValidationResult.Success;
    }
}
</code></pre>

<p>Basiclly if isfeature is true then Featurettes MUST have a value!</p>

<p>Error im getting:</p>

<blockquote>
  <p>An object reference is required for the non-static field, method, or
  property 'EducationViewModel.IsFeaturette'</p>
</blockquote>

<p>I can not make this property static cuz that would give me problems since this property is set with enityframework and I don't wish to change any of this. How can I accomplish this without making the property static?</p>