Question: I have the following two properties in my model:

```
        [Display(ResourceType = typeof(WideFormatStrings), Name = "labelDynamicWidth")]
        public int? SelectedDynamicWidth { get; set; }

        [Display(ResourceType = typeof(WideFormatStrings), Name = "labelDynamicHeight")]
        public int? SelectedDynamicHeight { get; set; }

```

How can i make a validation attribute that will check that at least one of them is less then some number .. say 100 (The number is a variable from the DB).

Answer: 
[ExpressiveAnnotations](https://www.nuget.org/packages/ExpressiveAnnotations/) has support for this. [Here is the documentation](https://github.com/JaroslawWaliszko/ExpressiveAnnotations). Something like this would accomplish what you want:

```
[AssertThat("SelectedDynamicWidth + SelectedDynamicHeight < 100")]
public int SelectedDynamicWidth { get; set; }

```

If the 100 is coming from the DB, youll most likely have to grab the value from the DB and put in a property in the view model:

```
[AssertThat("SelectedDynamicWidth + SelectedDynamicHeight < MaxSelectedDynamicValue")]
public int SelectedDynamicWidth { get; set; }

public int MaxSelectedDynamicValue { get; set; }

```
There is a thread about the different options to do conditional validation:[ASP.NET MVC Conditional validation](https://stackoverflow.com/questions/2417113/asp-net-mvc-conditional-validation).

I think that a self validating model (implementing IValidatableObject) might solve your problem. You can find and example in the next entry [How do I use IValidatableObject?](https://stackoverflow.com/questions/3400542/how-do-i-use-ivalidatableobject)