Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi Guys,

Recently i read the article on database validation for common regular expression like email, phone number and URL etc.

i would like to get some opinion on these three, which is better? or which combination is better? to make your code secure.

1) client side validation using j Query,JavaScript.
-> fast , UI can be manage properly using j query css
-> can be break by security software like burp
2) server side validation using required / regular expression validation
-> somewhat secure to burp like tools.
-> can be heavy if we have lot of validation control on single form
-> code can be lengthy if we have lot of validation / data annotation rules / other custom business logic related code.
3) database validation
-> provide more security
-> require custom error handling setup to manage proper UI
-> one time code for user define function
-> every time requires a round trip to server.

Now, we already know that database already doing some kind of validation based on column datatype and constraint like unique key etc. in this case is it okay to avoid code side validation directly and / or how we should manage this?
Posted

"Better" is the Boolean operator you still have to define on the set of techniques, but I doubt you can do it. Better for what? It makes your question invalid.

All types of validation have its importance. In every specific case, certain subset of them should be used, ranging from "none of them" to "all of them". But you've built the set of techniques not quite correctly. The mistaken one is about the server-side validation. You should have written just "server-side validation". Depending on the validation criteria you may or may not use Regular Expression or something else. By the way, asking questions on how to use Regular Expression for some criteria where this technique it totally unsuitable is one of the typical mistakes we often see on this forum.

—SA
 
Share this answer
 
v2
Comments
BillWoodruff 27-Jan-16 2:55am    
""Better" is the Boolean operator you still have to define on the set of techniques"

That alone is #5 worthy, and quote worthy !
I think the choice of techniques will depend on the current context, and the "probable anticipated future" context(s).

By context, I mean:

1. location: of database, users, code: highly-secured intranet / network share ? open network subject to hacking ? etc.

2. users: limited, unlikely to increase ? load will vary greatly in an unpredictable way ? it is certain the load will increase predictably, or unpredictably ? extreme scaling required from the start ?

3. code and administration: predictably excellent ? outsourced and perhaps irregular support, monitoring ? code-base/database subject to hacking ? best-in-breed industrial security procedures required ?

4. hardware: users' pc's, server hardware ... capacity, performance, reliability.
 
Share this answer
 
Comments
ravikhoda 27-Jan-16 3:50am    
thanks for the reply. i will keep this things in mind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900