Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved * Unauthorized copying of this file, via any medium is strictly prohibited * Proprietary and confidential * Written and maintained by the Click & Push Development team * <dev@clicknpush.ca>, January 2022 */ import axios from 'axios'; import * as Yup from "yup"; import { API_URL } from '../utils/RequestUtils'; import {reportAxiosError} from '../libs/auth/core' /** * String enum for type of registration validation request to send to server */ type RegisterCredsValidationType = 'usernamevalidation' | 'emailvalidation'; export interface RegisterCredsValues { email: string; username: string; } const uniqueValidation = async (validationEndpoint: RegisterCredsValidationType, valueToValidate: string): Promise<boolean> => { try { const data = new FormData() data.append('input', valueToValidate) const response = await axios({ method: 'POST', url: API_URL + '/api/' + validationEndpoint + '/', data: data, }); if (response.data.valid) { return true; } else { return false; } } catch (error) { reportAxiosError('Username validation request failed.', error); return false; } } export const credsSchema = Yup.object({ username: Yup .string() .trim() .required("You must enter a username.") .min(5, "Your username must be atleast 5 characters long.") .test("unique-username", "This username is already in use", async (value) => await uniqueValidation("usernamevalidation", value)), email: Yup .string() .trim() .required("You must enter an email.") .email("You must enter a valid email.") .test("unique-email", "This email is already in use", async (value) => await uniqueValidation("emailvalidation", value)), }) export const profileCredsSchema = Yup.object({ username: Yup .string() .trim() .required("You must enter a username.") .min(5, "Your username must be atleast 5 characters long."), email: Yup .string() .trim() .required("You must enter an email.") .email("You must enter a valid email.") }) export const passwordSchema = Yup.object({ password: Yup.string().trim().required("You must enter a password.").matches(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[\w~@#$%^&*+=`|{}:;!.?\"()\[\]-]{8,}$/, "Your password must be a minimum of 8 characters and contain 1 special character and 1 number."), confirmPassword: Yup.string().trim().required("You must confirm your password.").oneOf([Yup.ref('password'), null], "Your passwords must match.") }) |