Skip to content

Commit

Permalink
refatora validação de dados na função updateSnippet para melhorar a l…
Browse files Browse the repository at this point in the history
…egibilidade
  • Loading branch information
Jonhvmp committed Dec 7, 2024
1 parent 9944106 commit fb4d9cc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/src/controllers/snippetController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ export const updateSnippet = async (req: Request, res: Response, next: NextFunct
const { title, description, language, tags, code, favorite } = req.body;

// Validate input data
if (typeof title !== 'string' || typeof description !== 'string' || typeof language !== 'string' || !Array.isArray(tags) || typeof code !== 'string' || typeof favorite !== 'boolean') {
if (typeof title !== 'string' ||
typeof description !== 'string' ||
typeof language !== 'string' ||
!Array.isArray(tags) ||
typeof code !== 'string' ||
typeof favorite !== 'boolean') {
return handleValidationError(res, 'Dados inválidos.');
}

Expand Down

0 comments on commit fb4d9cc

Please sign in to comment.