1

That's what I'm looking for:

[RequiredIf("IsNewClient", true, ErrorMessage =*The value of other (string) property*)]

That's would be even better:

[RequiredIf("IsNewClient", true, ErrorMessage =*Calling a function and get the value*)]
  • If you take a look at the code (https://github.com/leniel/foolproof/tree/master/Foolproof) you'll see that Foolproof doesn't provide this functionality. So you'd have to subclass `RequiredIfAttribute` and add it yourself if you want it. I think you'll have trouble implementating the behavior you want though, see: http://stackoverflow.com/questions/7705386/is-it-possible-to-have-a-delegate-as-attribute-parameter – Oliver Mar 10 '17 at 08:50

1 Answers1

1

You can use a similar approach like that:

[RequiredIf("GoAbroad == true")]
public string PassportNumber { get; set; }

For more information have a look at ExpressiveAnnotations. Hope this helps...

Murat Yıldız
  • 11,299
  • 6
  • 63
  • 63