Where to put regular expression checks?

r0land013

R0land013

Posted on August 1, 2021

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.

💖 💪 🙅 🚩
r0land013
R0land013

Posted on August 1, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related