[Remote] Validator in Orchard

Topics: General, Troubleshooting, Writing modules
Feb 23, 2012 at 5:21 AM

Does anyone have an example using the [Remote] validation attribute in Orchard?
I am following this:http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-1
But the action is never being called. I have applied the attribute to a field on my Part that is being used through a driver.

I need the validation to happen as late as possible and it has to call a service to do the validation so I can't use a normal custom validator (no way to inject the needed service).

[
Remote("ValidateNewRegistrationIsUnique", "CourseAdmin", "CR.CourseManagement", AdditionalFields="CourseId", ErrorMessage="This registration is invalid. It would create a duplicate for this user.")]
Here is the controller action
public ActionResult ValidateNewCourseRegistrationIsUnique(int userId, int courseId)
{
    return Json(true); //for now
}

 

 

 

Any ideas, or a better alternative to Remote?

Thanks,
Will

Feb 23, 2012 at 2:14 PM

Any reason you can't validate in the driver's Update method?

Feb 23, 2012 at 2:28 PM

This might be related or identical to the issue here: http://orchard.codeplex.com/workitem/18269

I'm keeping an eye on the bug because I want to add some client validation to parts of my app at some point.