From b0f44cbad2a868d729ce159fb440c2ec5d745769 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Tue, 21 Apr 2020 03:47:31 +0530 Subject: [PATCH] :bug: Fix validations with new schema --- src/controllers/organization/memberships.ts | 10 +++++++--- src/controllers/user/index.ts | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/controllers/organization/memberships.ts b/src/controllers/organization/memberships.ts index 115b1a2cc..9deb52269 100644 --- a/src/controllers/organization/memberships.ts +++ b/src/controllers/organization/memberships.ts @@ -56,8 +56,12 @@ export class OrganizationMembershipsController { joiValidate( { organizationId: Joi.string().required(), - newMemberName: Joi.string().min(6).required(), - newMemberEmail: Joi.string().email().required(), + newMemberName: Joi.string() + .min(6) + .required(), + newMemberEmail: Joi.string() + .email() + .required(), role: Joi.number(), }, { @@ -100,7 +104,7 @@ export class OrganizationMembershipsController { @Middleware( validator( { - role: Joi.number().min(1).max(5), + role: Joi.string().allow(["OWNER", "ADMIN", "RESELLER", "MEMBER"]), }, "body" ) diff --git a/src/controllers/user/index.ts b/src/controllers/user/index.ts index 37f555c52..778a27cd9 100644 --- a/src/controllers/user/index.ts +++ b/src/controllers/user/index.ts @@ -55,14 +55,22 @@ export class UserController { primaryEmail: Joi.string(), countryCode: Joi.string().length(2), password: Joi.string().min(6), - gender: Joi.string().length(1), + gender: Joi.string().allow(["MALE", "FEMALE", "NONBINARY", "UNKNOWN"]), preferredLanguage: Joi.string() .min(2) .max(5), timezone: Joi.string(), - notificationEmails: Joi.number(), - prefersReducedMotion: Joi.boolean(), - prefersColorSchemeDark: Joi.boolean(), + notificationEmails: Joi.string().allow([ + "ACCOUNT", + "UPDATES", + "PROMOTIONS", + ]), + prefersReducedMotion: Joi.string().allow(["NO_PREFERENCE", "REDUCE"]), + prefersColorScheme: Joi.string().allow([ + "NO_PREFERENCE", + "LIGHT", + "DARK", + ]), profilePicture: Joi.string(), checkLocationOnLogin: Joi.boolean(), },