Validación fluida en MVC: especifique RuleSet para la validación del lado del cliente

En mi proyecto ASP.NET MVC 4 tengo un validador para uno de mis modelos de vista, que contiene la definición de reglas para RuleSets.Edit conjunto de reglas utilizado en la acción posterior, cuando se pasa toda la validación del cliente.Url yEmail conjunto de reglas reglas utilizadas enEdit conjunto de reglas (puede verlo a continuación) y en acciones especiales de ajax que validan solo el correo electrónico y solo la URL en consecuencia.

Mi problema es que la vista no sabe que debería usarEdit conjunto de reglas para la generación de atributos html del cliente y usodefault conjunto de reglas, que está vacío.¿Cómo puedo decirle a view que use?Edit conjunto de reglas para la generación de atributos de entrada?

Modelo:

public class ShopInfoViewModel
{
    public long ShopId { get; set; }

    public string Name { get; set; }

    public string Url { get; set; }

    public string Description { get; set; }

    public string Email { get; set; }
}

Validador:

public class ShopInfoViewModelValidator : AbstractValidator<ShopInfoViewModel>
{
    public ShopInfoViewModelValidator()
    {
        var shopManagementService = ServiceLocator.Instance.GetService<IShopService>();

        RuleSet("Edit", () =>
        {
            RuleFor(x => x.Name)
                .NotEmpty().WithMessage("Enter name.")
                .Length(0, 255).WithMessage("Name length should not exceed 255 chars.");

            RuleFor(x => x.Description)
                .NotEmpty().WithMessage("Enter name.")
                .Length(0, 10000).WithMessage("Name length should not exceed 10000 chars.");

            ApplyUrlRule(shopManagementService);
            ApplyEmailRule(shopManagementService);
        });

        RuleSet("Url", () => ApplyUrlRule(shopManagementService));
        RuleSet("Email", () => ApplyEmailRule(shopManagementService));
    }

    private void ApplyUrlRule(IShopService shopService)
    {
        RuleFor(x => x.Url)
            .NotEmpty().WithMessage("Enter url.")
            .Length(4, 30).WithMessage("Length between 4 and 30 chars.")
            .Matches(@"[a-z\-\d]").WithMessage("Incorrect format.")
            .Must((model, url) => shopService.Available(url, model.ShopId)).WithMessage("Shop with this url already exists.");
    }

    private void ApplyEmailRule(IShopService shopService)
    {
        // similar to url rule: not empty, length, regex and must check for unique
    }
}

Ejemplo de acción de validación:

 public ActionResult ValidateShopInfoUrl([CustomizeValidator(RuleSet = "Url")]
        ShopInfoViewModel infoViewModel)
 {
     return Validation(ModelState);
 }

Obtener y publicar acciones paraShopInfoViewModel:

[HttpGet]
public ActionResult ShopInfo()
{
    var viewModel = OwnedShop.ToViewModel();
    return PartialView("_ShopInfo", viewModel);
}

[HttpPost]
public ActionResult ShopInfo(CustomizeValidator(RuleSet = "Edit")]ShopInfoViewModel infoViewModel)
    {
        var success = false;

        if (ModelState.IsValid)
        {
            // save logic goes here
        }
    }

La vista contiene el siguiente código:

@{
    Html.EnableClientValidation(true);
    Html.EnableUnobtrusiveJavaScript(true);
}
<form class="master-form" action="@Url.RouteUrl(ManagementRoutes.ShopInfo)" method="POST" id="masterforminfo">
    @Html.TextBoxFor(x => x.Name)
    @Html.TextBoxFor(x => x.Url, new { validationUrl = Url.RouteUrl(ManagementRoutes.ValidateShopInfoUrl) })
    @Html.TextAreaFor(x => x.Description)
    @Html.TextBoxFor(x => x.Email, new { validationUrl = Url.RouteUrl(ManagementRoutes.ValidateShopInfoEmail) })
    <input type="submit" name="asdfasfd" value="Сохранить" style="display: none">
</form>

Entrada html de resultados (sin ningún atributo de validación del cliente):

<input name="Name" type="text" value="Super Shop"/> 

Respuestas a la pregunta(3)

Su respuesta a la pregunta