In MVC2, how do I validate fields that aren't in my data model?

Posted by Andy Evans on Stack Overflow See other posts from Stack Overflow or by Andy Evans
Published on 2010-05-22T03:45:30Z Indexed on 2010/05/22 3:50 UTC
Read the original article Hit count: 305

Filed under:

I am playing with MVC2 in VS 2010 and am really getting to like it. In a sandbox application that I've started from scratch, my database is represented in an ADO.NET entity data model and have done much of the validation for fields in my data model using Scott Guthrie's "buddy class" approach which has worked very well.

However, in a user registration form that I have designed and am experimenting with, I'd like to add a 'confirm email address' or a 'confirm password' field. Since these fields obviously wouldn't exist in my data model, how would I validate these fields client side and server side?

I would like to implement something like 'Html.ValidationMessageFor', but these fields don't exist in the data model. Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2