update to python fastpi
This commit is contained in:
95
Frontend/src/utils/validationSchemas.ts
Normal file
95
Frontend/src/utils/validationSchemas.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import * as yup from 'yup';
|
||||
|
||||
/**
|
||||
* Login Validation Schema
|
||||
*/
|
||||
export const loginSchema = yup.object().shape({
|
||||
email: yup
|
||||
.string()
|
||||
.required('Email is required')
|
||||
.email('Invalid email')
|
||||
.trim(),
|
||||
password: yup
|
||||
.string()
|
||||
.required('Password is required')
|
||||
.min(8, 'Password must be at least 8 characters'),
|
||||
rememberMe: yup
|
||||
.boolean()
|
||||
.optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Register Validation Schema
|
||||
*/
|
||||
export const registerSchema = yup.object().shape({
|
||||
name: yup
|
||||
.string()
|
||||
.required('Full name is required')
|
||||
.min(2, 'Full name must be at least 2 characters')
|
||||
.max(50, 'Full name must not exceed 50 characters')
|
||||
.trim(),
|
||||
email: yup
|
||||
.string()
|
||||
.required('Email is required')
|
||||
.email('Invalid email')
|
||||
.trim(),
|
||||
password: yup
|
||||
.string()
|
||||
.required('Password is required')
|
||||
.min(8, 'Password must be at least 8 characters')
|
||||
.matches(
|
||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])/,
|
||||
'Password must contain uppercase, lowercase, ' +
|
||||
'number and special character'
|
||||
),
|
||||
confirmPassword: yup
|
||||
.string()
|
||||
.required('Please confirm password')
|
||||
.oneOf([yup.ref('password')], 'Passwords do not match'),
|
||||
phone: yup
|
||||
.string()
|
||||
.optional()
|
||||
.matches(
|
||||
/^[0-9]{10,11}$/,
|
||||
'Invalid phone number'
|
||||
),
|
||||
});
|
||||
|
||||
/**
|
||||
* Forgot Password Validation Schema
|
||||
*/
|
||||
export const forgotPasswordSchema = yup.object().shape({
|
||||
email: yup
|
||||
.string()
|
||||
.required('Email is required')
|
||||
.email('Invalid email')
|
||||
.trim(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Reset Password Validation Schema
|
||||
*/
|
||||
export const resetPasswordSchema = yup.object().shape({
|
||||
password: yup
|
||||
.string()
|
||||
.required('New password is required')
|
||||
.min(8, 'Password must be at least 8 characters')
|
||||
.matches(
|
||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])/,
|
||||
'Password must contain uppercase, lowercase, ' +
|
||||
'number and special character'
|
||||
),
|
||||
confirmPassword: yup
|
||||
.string()
|
||||
.required('Please confirm password')
|
||||
.oneOf([yup.ref('password')], 'Passwords do not match'),
|
||||
});
|
||||
|
||||
// Types
|
||||
export type LoginFormData = yup.InferType<typeof loginSchema>;
|
||||
export type RegisterFormData =
|
||||
yup.InferType<typeof registerSchema>;
|
||||
export type ForgotPasswordFormData =
|
||||
yup.InferType<typeof forgotPasswordSchema>;
|
||||
export type ResetPasswordFormData =
|
||||
yup.InferType<typeof resetPasswordSchema>;
|
||||
Reference in New Issue
Block a user