Skip to content

Instantly share code, notes, and snippets.

@mosufy
Created June 5, 2021 01:41
Show Gist options
  • Save mosufy/0262c679a9ff821937886e64e71df9dc to your computer and use it in GitHub Desktop.
Save mosufy/0262c679a9ff821937886e64e71df9dc to your computer and use it in GitHub Desktop.
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