DEV Community

R0land013
R0land013

Posted on

Where to put regular expression checks?

Hello. I would like to know where should I check if a specific attribute matches with some regular expression. Should I do it in the class or in the database. For example imagine I have an User class, which has an email attribute, and I need to check if a given value for that property is correctly written. Also imagine I need to store the users in a database. Where should I check for the correctly written email, in the code inside the User class, in the database or both? Thank you.

Top comments (0)