1

I'm trying to combine RequiredIfNot and Range validators, without success.
The deal is: when the condition on RequiredIfNot attribute is false, the Range attribute starts to work, but it doesn't work.

Actually, the code I have is...

[Range(1, 100, "Out of the range")]
[RequiredIfNot("Field", "Value", "This field is required")]
public string TVCount { get; set; }

... but the Range validator works everytime, and I want that it works only if RequiredIfNot condition were false.

Is there a way (simple or not) to do this?

Andrii Kalytiiuk
  • 1,501
  • 14
  • 26
Kiwanax
  • 1,265
  • 1
  • 22
  • 41

1 Answers1

1

Accordingly to this article, you should just create you own Validation Attribute.

Community
  • 1
  • 1
Agat
  • 4,577
  • 2
  • 34
  • 62