1

I have a model, the model has 2 strings; foo and bar.

foo is what it is, it will be one of x amount of possible values (it's not an enum, though).

bar is entered by the user, so I want to validate it. But I want the validation to be driven by foo, and I want to use Remote validation (to do it remotely).

My suggestion:

Create a controller MyValidationController with an action that the remote validation attribute will point to. To this action, I'll send values of foo and bar.

The action will then redirect to the action that corresponds to foo. So, if foo is "MyValue", I will call RedirectToAction("MyValue"). And the MyValue action will validate accordingly.

Assuming I've found a way to ensure this action exists, my question is:

Am I reinventing the wheel here? Is there a feature in MVC that would allow me to validate with a rule driven by a property submitted in the same form?

JᴀʏMᴇᴇ
  • 2,351
  • 4
  • 22
  • 25

0 Answers0