Hi
I am trying to go through this tutorial tutorial . This tutorial seems to do everything that I been looking for but I am having trouble trying to understand it.
Maybe it is because I don't know enough of Xval, jquery.validate.
1st He seems to be using a typed view: RemoteValidation.Models.User. What happens if I want to pass some other data, how would I get by this? Do I have to make another class store the User model and the other stuff I want in it?
2nd
I get confused a lot through the article since this is suppost to be like client and server side validtion but then he adds lines like
“//add optional regEx validator to minimize ajax requests”
So to me this rasies the question of I thought they already had this in place:
[RegularExpression(EmailRegEx, ErrorMessage = "Invalid e-mail address.")]”
Then he has this
“For example, all you’d need to implement for server AND remote client-side validation of password strength is this: ”
public class IsSafePasswordAttribute : RemotePropertyValidator
{
public IsSafePasswordAttribute()
{
//perform some simple password strength check with a regular expression
//on the client side first
ClientSideRegEx = “.{8,20}”;
}
protected override bool PropertyValid(object value)
{
//Insert more elaborate server-side / remote client side password checking
// logic and return result here…
}
So then if you read the comments it seems like the constructor is for client side and this PropertyValid is for server side?
Is this correct? What happens if I just want the same thing for both client and server side?
But then he has this
protected override bool PropertyValid(object value)
{
return (string)value != “[email protected]”;
}
This code gets run like if it was just on the client side.
I don't get
ClientSideRegEx = “.{8,20}”;
First this now really tells me that it is for only the ClientSide so that means I would have to write the same code for the server side? I thought that was the whole purpose of this to not write the same code twice?
Also don't they have one of these "[]" for range like they have for required? I would think that would a very basic one so what would you need to make your own?
I also don't understand how he figured out that's how it needs to be inputed. Like is there so documentation I can look at. I know it is a regex expression but I am wondering about other validation and stuff.
[Files in the Demo]
Then overall I don’t know what to I should be changing and what I can leave alone. Like if I start a new project and start doing my validation do I include these files?
DataAnnotationsModelBinder.cs ExtensionMethods.cs RemoteValidators.cs
Plus of course the xval files. Do I need to change any of these .cs files? Or can I use them as is? Like do I just start inheriting the “RemotePropertyValidator” and just start typing or do I have to do some other changes?
Then on a side note do they still make Xval I was looking on the site and its only 0.8(and only beta still) right now and has not been updated in a couple months. I posted this question "if they where still being developed" and no response yet.
That gives me a uneasy feeling.
Thanks
P.S I am open of using other stuff then xval if it can do the same thing(easier). As long as it hooks up with jquery and asp.net mvc.