Created
June 5, 2021 01:41
-
-
Save mosufy/0262c679a9ff821937886e64e71df9dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createNewAccount = async (params) => { | |
const validated = validateCreateNewAccountParameters(params); | |
if (!validated) { | |
throw new Error('Validation error'); | |
} | |
const usernameExists = await checkUsernameExists(params.username); | |
if (usernameExists) { | |
throw new Error('Username already exists'); | |
} | |
const emailExists = await checkEmailExists(params.email); | |
if (emailExists) { | |
throw new Error('Email already exists'); | |
} | |
return insertUser(params); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment