0

Is it possible to have a model as a list in a view i.e.

@model List<SomeViewModel>

and to have a class

public class SomeViewModel
{
      public int id { get; set; }
      public string value { get; set; }
      [OrHereCustomValidationAttribute]
      public SomeProp someProp { get; set; }
}

public class SomeProp
{
     [CustomValidationAttribute]
     public int propID { get; set; }
     [CustomValidationAttribute]
     public string propValue { get; set; }
}

I need to check if the propID is equal to some value in one list item, and set the validation rule of propValue in another list item. How to do that? In any case, not sure where to put attribute, but the biggest problem is how to get an item from outside the object.

HomeMade
  • 552
  • 4
  • 10
  • 21
  • Possible duplicate of [Custom validation attribute that compares the value of my property with another property's value in my model class](https://stackoverflow.com/questions/11959431/custom-validation-attribute-that-compares-the-value-of-my-property-with-another) – OnePage Sep 24 '19 at 15:57
  • It's not, I don't try to compare two properties of one model, but two properties of two objects in a list – HomeMade Sep 30 '19 at 08:05

0 Answers0