4

Is there a lsit of what validation rule types are directly available, without having to code a new one?

e.g.

JQuery.validation has "min(value)"

But I have tried

var rule = new ModelClientValidationRule();
rule.ErrorMessage = ErrorMessage;
rule.ValidationParameters.Add("required", true);
rule.ValidationParameters.Add("min", _minDate);
rule.ValidationType = "min";
yield return rule;

without success.

Are the only options the inherited classes?

0

2 Answers 2

5

Taken from jquery documentation, I would suspect you cannot use date type but convert your date to a number and it will probably work.

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

What number is required for Date?
var aDate = $("#date").val().split('-'); var epoch = new Date(aDate[0] + "," + aDate[1] + "," + aDate[2]).getTime() / 1000;
Can't get it to work at all :( Was hoping not to have to write my own validatiobn functions.
0

Refer to Remote Client Side Validation with FluentValidation, you can make use of the existing remote validator by doing

            var rule = new ModelClientValidationRule
            {
                ValidationType = "remote",
                ErrorMessage = message
            };
            rule.ValidationParameters.Add("url", "/api/validation/uniqueemail");

            yield return rule;

I think you can change the type you want to use by specify the ValidationType.

You can get the List of built-in Validation methods. Refer to that table, it includes the required and min you need.

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.