Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Specify a ruleset on a model instance?

$
0
0

I understand that I can specify a ruleset when model binding takes place eg.

 

[HttpPost]
public ActionResult Edit([CustomizeValidator(RuleSet = "Edit")]EmployeeCreateEditViewModel viewModel)
{...}

 

But how can I specify the ruleset when I'm passing my viewmodel instance to my view so the correct client-side code is put on the page controls i.e the page 'building' and not the page saving as above

 

public ViewResult Edit(int id)
{
    EmployeeCreateEditViewModel viewModel = new EmployeeEditViewModelBuilder().BuildForEmployee(id);

    return View(viewModel);
}

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>