Compare commits
No commits in common. "ccc3d9c2503318b793cccb424b0d1fb8a8244529" and "f46d9cdc8d202d21f1f7d0d6704d3499087ef64a" have entirely different histories.
ccc3d9c250
...
f46d9cdc8d
26
src/App.tsx
26
src/App.tsx
|
|
@ -6,7 +6,7 @@ import { getCountryRuleByName } from './constants/countries';
|
||||||
import type { ModuleItem, Currency, UserProfile, VerificationResult, PublicPlan } from './types';
|
import type { ModuleItem, Currency, UserProfile, VerificationResult, PublicPlan } from './types';
|
||||||
import { API_BASE } from './services/api';
|
import { API_BASE } from './services/api';
|
||||||
import { loadRazorpayScript } from './services/razorpay';
|
import { loadRazorpayScript } from './services/razorpay';
|
||||||
import { cleanPhoneInput, validatePhoneNumber, validatePassword, validateEmail } from './utils/validation';
|
import { cleanPhoneInput, validatePhoneNumber, validatePassword } from './utils/validation';
|
||||||
|
|
||||||
// Modular Subcomponents
|
// Modular Subcomponents
|
||||||
import { StoreHeader } from './components/layout/StoreHeader';
|
import { StoreHeader } from './components/layout/StoreHeader';
|
||||||
|
|
@ -408,9 +408,15 @@ export default function App() {
|
||||||
|
|
||||||
const trimmedEmail = authEmail.trim();
|
const trimmedEmail = authEmail.trim();
|
||||||
|
|
||||||
const emailErr = validateEmail(trimmedEmail);
|
if (!trimmedEmail) {
|
||||||
if (emailErr) {
|
setAuthError('Email address is required.');
|
||||||
setAuthError(emailErr);
|
setAuthLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
if (!emailRegex.test(trimmedEmail)) {
|
||||||
|
setAuthError('Please enter a valid email address.');
|
||||||
setAuthLoading(false);
|
setAuthLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -546,9 +552,15 @@ export default function App() {
|
||||||
setResetSuccessMessage(null);
|
setResetSuccessMessage(null);
|
||||||
|
|
||||||
const trimmedEmail = authEmail.trim();
|
const trimmedEmail = authEmail.trim();
|
||||||
const emailErr = validateEmail(trimmedEmail);
|
if (!trimmedEmail) {
|
||||||
if (emailErr) {
|
setAuthError('Email address is required.');
|
||||||
setAuthError(emailErr);
|
setAuthLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
if (!emailRegex.test(trimmedEmail)) {
|
||||||
|
setAuthError('Please enter a valid email address.');
|
||||||
setAuthLoading(false);
|
setAuthLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,24 +179,3 @@ export const validatePassword = (password: string, fieldName = 'Password'): stri
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* RFC 5322 & RFC 1035 compliant email validation regex.
|
|
||||||
* Disallows invalid domain characters (e.g. + in domain like +gmail+.com, consecutive dots, leading/trailing hyphens)
|
|
||||||
* while properly accepting plus-addressing in local-part (e.g. sanskar+sarak@gmail.com).
|
|
||||||
*/
|
|
||||||
export const EMAIL_REGEX = /^[a-zA-Z0-9_%+-]+(?:\.[a-zA-Z0-9_%+-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/;
|
|
||||||
|
|
||||||
export const validateEmail = (email?: string | null): string | null => {
|
|
||||||
if (!email || !email.trim()) {
|
|
||||||
return 'Email address is required.';
|
|
||||||
}
|
|
||||||
if (!EMAIL_REGEX.test(email.trim())) {
|
|
||||||
return 'Please enter a valid email address.';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isValidEmail = (email?: string | null): boolean => {
|
|
||||||
return validateEmail(email) === null;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue