diff --git a/api/src/cli/commands/init/index.ts b/api/src/cli/commands/init/index.ts index c0232737e4..5067316b2a 100644 --- a/api/src/cli/commands/init/index.ts +++ b/api/src/cli/commands/init/index.ts @@ -4,6 +4,7 @@ import inquirer from 'inquirer'; import { Knex } from 'knex'; import ora from 'ora'; import { v4 as uuidV4 } from 'uuid'; +import Joi from 'joi'; import runMigrations from '../../../database/migrations/run'; import runSeed from '../../../database/seeds/run'; import createDBConnection, { Credentials } from '../../utils/create-db-connection'; @@ -75,6 +76,12 @@ export default async function init(): Promise { name: 'email', message: 'Email', default: 'admin@example.com', + validate: (input: string) => { + const emailSchema = Joi.string().email().required(); + const { error } = emailSchema.validate(input); + if (error) throw new Error('The email entered is not a valid email address!'); + return true; + }, }, { type: 'password',