CLASSROOMIO-T-5: Educators Settings CRUD

Co-authored-by: Rotimi Best <rotimiibitoyeemma@gmail.com>

Merge-request: CLASSROOMIO-MR-7
Merged-by: Digdippa Team <digdippa@gmail.com>
This commit is contained in:
Rotimi Best
2023-05-02 23:55:26 +00:00
committed by Space Cloud
co-authored by Rotimi Best
parent 01a1f0f907
commit 5f14b36ef8
27 changed files with 832 additions and 89 deletions
+31
View File
@@ -1,4 +1,5 @@
import z from 'zod';
import { validateEmail } from './validateEmail';
const forgotValidationSchema = z.object({
email: z.string().email({
@@ -100,3 +101,33 @@ export const onboardingValidation = (fields = {}, step) => {
export const getDisableSubmit = ({ password, confirmPassword }) => {
return !!(password && confirmPassword && password !== confirmPassword);
};
export const validateEmailInString = (emailsStr) => {
let error = '';
let hasError = false;
if (!emailsStr) {
return {
hasError: true,
error: 'Enter an email',
emails: [],
};
}
const emails = emailsStr.split(',').map((_email) => {
const email = _email.trim();
if (!validateEmail(email)) {
hasError = true;
error += !error.length ? `Not valid email: ${email}` : `, ${email}`;
}
return email;
});
return {
hasError,
error,
emails,
};
};