brief-06-back/src/utils/validators.util.ts
Mathis 1ad136ea60
feat: Implement registration feature and update database service
This commit creates new methods for the authentication system, especially the user registration feature. The update also validates input data and checks if a user already exists in the database. It modifies the application entry point to include the updated user registration route and provides updates to the database service to include user-related functions. The MariaDB collation was also updated in the database schema script to support unicode.
2024-05-21 16:14:54 +02:00

18 lines
501 B
TypeScript

const Validators = {
isEmail: (value: string) => {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,32}$/;
return emailRegex.test(value)
},
isUsername: (value: string) => {
const usernameRegex = /^[a-zA-Z0-9._]{3,14}$/;
return usernameRegex.test(value);
},
//displayName
isPassword: (value: string) => {
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,32}$/;
return passwordRegex.test(value);
}
}
export default Validators