From 1090cc0bfe43c957eba7cf466b8c06b65df48d7e Mon Sep 17 00:00:00 2001 From: Tom Pretty Date: Mon, 15 Feb 2021 08:38:46 +0000 Subject: [PATCH] Fix validation --- src/create-reminder-signup/lambda/lambda.ts | 1 - src/create-reminder-signup/lambda/local.ts | 1 - src/create-reminder-signup/lambda/models.ts | 14 +++++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/create-reminder-signup/lambda/lambda.ts b/src/create-reminder-signup/lambda/lambda.ts index b9f960d..c79553b 100644 --- a/src/create-reminder-signup/lambda/lambda.ts +++ b/src/create-reminder-signup/lambda/lambda.ts @@ -103,7 +103,6 @@ const createSignup = async ( body: 'Invalid body', }; } - console.log(signupRequest); const token = await identityAccessTokenPromise; const pool = await dbConnectionPoolPromise; diff --git a/src/create-reminder-signup/lambda/local.ts b/src/create-reminder-signup/lambda/local.ts index a9617c4..5c01db4 100644 --- a/src/create-reminder-signup/lambda/local.ts +++ b/src/create-reminder-signup/lambda/local.ts @@ -17,7 +17,6 @@ function runLocal() { body: JSON.stringify({ email: 'test-reminders10@theguardian.com', reminderPeriod: '2021-01-01', - reminderCreatedAt: 'foo', reminderFrequencyMonths: 3, reminderPlatform: 'WEB', reminderComponent: 'EPIC', diff --git a/src/create-reminder-signup/lambda/models.ts b/src/create-reminder-signup/lambda/models.ts index d21bfa1..1d8f753 100644 --- a/src/create-reminder-signup/lambda/models.ts +++ b/src/create-reminder-signup/lambda/models.ts @@ -38,29 +38,29 @@ function isValidEmail(email: string): boolean { type DateString = string; function isValidDateString(dateString: string): boolean { - console.log(dateString); const date = Date.parse(dateString); - console.log('after!'); return !isNaN(date); } export interface BaseSignupRequest { email: Email; country?: string; - reminderCreatedAt: DateString; + reminderCreatedAt?: DateString; reminderPlatform: ReminderPlatform; reminderComponent: ReminderComponent; reminderStage: ReminderStage; reminderOption?: string; } -export interface OneOffSignupRequest extends BaseSignupRequest { +// typecheck.macro doesn't support extends +export type OneOffSignupRequest = BaseSignupRequest & { reminderPeriod: DateString; -} +}; -export interface RecurringSignupRequest extends BaseSignupRequest { +// typecheck.macro doesn't support extends +export type RecurringSignupRequest = BaseSignupRequest & { reminderFrequencyMonths: number; -} +}; export interface APIGatewayEvent { headers: Record;