Skip to content

Commit

Permalink
chore: update tag validation
Browse files Browse the repository at this point in the history
This commit updates the tag validation for Posts and Questions to set the maximum number of allowed tags to 3,
reflecting the change from min(3) to max(3). This aligns with the requirement that tags should be an array with up to three items.
  • Loading branch information
tobisupreme committed Aug 12, 2023
1 parent 9f2cd1c commit a389df7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/posts/postsValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const createPostValidator = Joi.object({
'string.empty': 'Title is required',
'any.required': 'Title is required',
}),
tags: Joi.array().items(Joi.string()).min(1).optional().messages({
tags: Joi.array().items(Joi.string()).max(3).optional().messages({
'array.min': 'Tags must be an array with at least one item',
'array.base': 'Tags must be an array with at least one item',
}),
});

const updatePostValidator = Joi.object({
content: Joi.string().optional(),
tags: Joi.array().items(Joi.string()).min(1).optional().messages({
tags: Joi.array().items(Joi.string()).max(3).optional().messages({
'array.min': 'Tags must be an array with at least one item',
'array.base': 'Tags must be an array with at least one item',
}),
Expand Down
4 changes: 2 additions & 2 deletions src/questions/questionsValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const createQuestionValidator = Joi.object({
'string.empty': 'Body is required',
'any.required': 'Body is required',
}),
tags: Joi.array().items(Joi.string()).min(1).optional().messages({
tags: Joi.array().items(Joi.string()).max(3).optional().messages({
'array.min': 'Tags must be an array with at least one item',
'array.base': 'Tags must be an array with at least one item',
}),
Expand All @@ -18,7 +18,7 @@ const createQuestionValidator = Joi.object({
const updateQuestionValidator = Joi.object({
title: Joi.string().optional().max(100),
body: Joi.string().optional(),
tags: Joi.array().items(Joi.string()).min(1).optional().messages({
tags: Joi.array().items(Joi.string()).max(3).optional().messages({
'array.min': 'Tags must be an array with at least one item',
'array.base': 'Tags must be an array with at least one item',
}),
Expand Down

0 comments on commit a389df7

Please sign in to comment.