First part of backend rework
- Added the base data structure for the new database - Added the new routes for the new database - Reworked the users endpoints
This commit is contained in:
30
modules/formatManager.js
Normal file
30
modules/formatManager.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import dns from 'dns';
|
||||
|
||||
export function isEmailDomainValid(email) {
|
||||
const domain = email.split('@')[1];
|
||||
return new Promise((resolve, reject) => {
|
||||
dns.lookup(domain, (err, address) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
const isIPAddress = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(address);
|
||||
resolve(isIPAddress);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function isValidEmail(email) {
|
||||
const emailRegex = /\S+@\S+\.\S+/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
|
||||
export function isNumber(x) {
|
||||
return /^-?[\d.]+(?:e-?\d+)?$/.test(x);
|
||||
}
|
||||
|
||||
export function isPhoneNumber(phone) {
|
||||
const phoneRegex = /^\d{10}$/;
|
||||
return phoneRegex.test(phone);
|
||||
}
|
||||
Reference in New Issue
Block a user