-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
398 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Joi from '@hapi/joi'; | ||
import { articleEdit } from '../schemas'; | ||
import { validateInputs } from '../helpers'; | ||
|
||
const options = { | ||
abortEarly: false | ||
}; | ||
|
||
/** | ||
* Validates user article input | ||
* | ||
* @param {string} req - ExpressJs request object | ||
* @param {string} res - ExpressJs response object | ||
* @param {string} next - ExpressJs next function | ||
* @returns {(JSON|function)} HTTP JSON response or ExpressJs next function | ||
*/ | ||
const articleEditValidation = (req, res, next) => { | ||
Joi.validate(req.body, articleEdit, options, validateInputs(res, next)); | ||
}; | ||
export default articleEditValidation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Joi from '@hapi/joi'; | ||
import { setCustomMessage } from '../helpers'; | ||
|
||
export default { | ||
description: Joi.string() | ||
.min(20) | ||
.max(500) | ||
.error(setCustomMessage('description')), | ||
title: Joi.string() | ||
.min(3) | ||
.max(250) | ||
.error(setCustomMessage('title')), | ||
status: Joi.string() | ||
.valid('publish', 'draft') | ||
.error(setCustomMessage('status', 'valid status')), | ||
articleBody: Joi.string() | ||
.min(2) | ||
.error(setCustomMessage('articleBody')), | ||
image: Joi.string() | ||
.uri() | ||
.error(setCustomMessage('image')), | ||
tags: Joi.string() | ||
.optional() | ||
.min(2) | ||
.max(250) | ||
.error(setCustomMessage('tags')) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import * as createArticle from './create.test'; | ||
import * as likeOrDislikeArticle from './likeOrDislikeArticle.test'; | ||
import * as removeArticleLikeOrDislike from './removeArticleLikeOrDislike.test'; | ||
import * as updateArticle from './update.test'; | ||
|
||
export { createArticle, likeOrDislikeArticle, removeArticleLikeOrDislike }; | ||
export { | ||
createArticle, likeOrDislikeArticle, removeArticleLikeOrDislike, updateArticle | ||
}; |
Oops, something went wrong.