Skip to content

Commit

Permalink
fix: social request validation, user update
Browse files Browse the repository at this point in the history
  • Loading branch information
HungLV46 committed Aug 19, 2024
1 parent 77380b8 commit bb23b36
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/apis/routes/products/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ export const createProductRoute: Hapi.ServerRoute = {
.optional()
.default([]),
metadata: Joi.object({
previews: Joi.array()
.items(Joi.string())
.default([])
.example([
'https://loremflickr.com/640/480?lock=1572275828555776',
'https://loremflickr.com/640/480?lock=1572275828555776',
]),
cta_url: Joi.string().default('').example('https://www.google.com'),
previews: Joi.array().optional().items(Joi.string()).default([]),
cta_url: Joi.string().optional().default(''),
socials: Joi.array()
.optional()
.items(Joi.object({ name: Joi.string(), url: Joi.string() }))
.default([]),
})
.optional()
.default({}),
.default({})
.example({
previews: [
'https://loremflickr.com/640/480?lock=1572275828555776',
'https://loremflickr.com/640/480?lock=1572275828555776',
],
cta_url: 'https://www.google.com',
socials: [
{ name: 'twitter', url: 'https://twitter.com' },
{ name: 'discord', url: 'https://discord.com' },
],
}),
collections: Joi.array()
.items(
Joi.object({
Expand Down
10 changes: 9 additions & 1 deletion src/apis/routes/products/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export const updateProductRoute: Hapi.ServerRoute = {
{ name: 'attribute name 2', value: 'attribute value 2' },
]),
metadata: Joi.object({
previews: Joi.array().items(Joi.string()).optional().default([]),
previews: Joi.array().optional().items(Joi.string()).default([]),
cta_url: Joi.string().optional().default(''),
socials: Joi.array()
.optional()
.items(Joi.object({ name: Joi.string(), url: Joi.string() }))
.default([]),
})
.optional()
.default({})
Expand All @@ -53,6 +57,10 @@ export const updateProductRoute: Hapi.ServerRoute = {
'https://loremflickr.com/640/480?lock=1572275828555776',
],
cta_url: 'https://www.google.com',
socials: [
{ name: 'twitter', url: 'https://twitter.com' },
{ name: 'discord', url: 'https://discord.com' },
],
}),
collections: Joi.array()
.items(
Expand Down

0 comments on commit bb23b36

Please sign in to comment.