tags:

views:

15

answers:

2

Hi, I need to store in a Table messages which are sent using a classical web page CONTACT US.

My question is: Would be better doing email validation on Business layer or better at Data Base level?

Regarding email validation in BL I would like to know if using asp.net 4 there is some sort of automatic system for validating emails instead of complicated regex or similar.

Regarding validation in DataBase I found out this article, seems quite useful.

http://vyaskn.tripod.com/handling_email_addresses_in_sql_server.htm

I would appreciate your opinions.

Thanks for your support :-)

A: 

I think what you want from asp.net is available http://www.beansoftware.com/ASP.NET-Tutorials/Validation-In-ASP.NET.aspx

As for the validation, I would do it at the business level so you can easily go back and get the user to correct their error. Doing it at the database level would mean going back up two levels to get a correction. Basically, validate as soon as possible to minimise problems.

gabe3886
thanks for your link, as i see is done using javasrcipt, would be great if would be done just by BL maybe in C#, if is done using client scripting like Javascript I am afraid some invalid data could pass.
GIbboK
+1  A: 

I would handle the validation at the business layer. I try to keep as much logic out of the database as possible.

Also, I don't worry about getting the perfect regex for email addresses. I usually just check that it contains an @ character. I don't want my validation to disallow some valid email address that I didn't think of. If I want to be sure that it's a good address, I'll send an email to it, and ask them to click a link to validate their email address.

Lance Fisher
thanks i will keep it mind!
GIbboK