Skip to content

Commit

Permalink
update dynamicUpdatePlatform
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Apr 24, 2024
1 parent 465ad00 commit 04d6d07
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/validations/platform.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import { objectId } from './custom.validation';
import { IAuthAndPlatform } from '../interfaces';
import { Types } from 'mongoose';

const discordMetadata = () => {
const discordCreateMetadata = () => {
return Joi.object().keys({
id: Joi.string().required(),
name: Joi.string().required(),
icon: Joi.string().required().allow(''),
});
};

const discordUpdateMetadata = () => {
return Joi.object().keys({
id: Joi.string().required(),
name: Joi.string().required(),
Expand All @@ -31,7 +39,7 @@ const createPlatform = {
switch: [
{
is: 'discord',
then: discordMetadata(),
then: discordCreateMetadata(),
},
{
is: 'twitter',
Expand Down Expand Up @@ -97,17 +105,9 @@ const dynamicUpdatePlatform = (req: Request) => {
params: Joi.object().keys({
platformId: Joi.required().custom(objectId),
}),
body: Joi.object()
.required()
.keys({
metadata: Joi.object()
.required()
.keys({
selectedChannels: Joi.array().items(Joi.string()),
period: Joi.date(),
analyzerStartedAt: Joi.date(),
}),
}),
body: Joi.object().required().keys({
metadata: discordUpdateMetadata
}),
};
}
default:
Expand Down

0 comments on commit 04d6d07

Please sign in to comment.