15

I tried to use GreaterThen validator and it looks like it doesn't support client-side validation. Is there a list of FluentValidation validators which support client-side validation?

3 Answers 3

26

The list of validators supported on the client is on this page and are as follows:

  • NotNull/NotEmpty (required)
  • Matches (regex)
  • InclusiveBetween (range)
  • CreditCard
  • Email
  • EqualTo (cross-property equality comparison)
  • Length
Sign up to request clarification or add additional context in comments.

2 Comments

Oh, how I missed it... Is there any specific reason why GreaterThan and similar validators are not supported on client-side?
@Idsa: Quoted from fluentvalidation.codeplex.com/discussions/256069: "The only validators that are client-side enabled out of the box are those that directly correspond to MVC's built-in client-side validators."
0

So far i know there is no list, you could create your own client side validator so create that createrthen works also on client side

Comments

0

You can use Form Helper. It adds client-side support to Fluent-Validation.

Startup.cs

services.AddFormHelper();
With configuration: (optional)

services.AddFormHelper(new FormHelperConfiguration
{
    CheckTheFormFieldsMessage = "Your custom message...",
    RedirectDelay = 6000,
    DebugMode = true
});

View:

var formConfig = new FormConfig(ViewContext)
{
    FormId = "ProductForm",
    FormTitle = "New Product",
    BeforeSubmit = "ProductFormBeforeSubmit", // optional
    Callback = "ProductFormCallback" // optional,
};

// <form id="@formConfig.FormId" asp-controller="Home" asp-action="Save"
// ...

@await Html.RenderFormScript(formConfig)

Controller:

[HttpPost, FormValidator]
public IActionResult Save(FormViewModel viewModel)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.