mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
task types: add new error messages for invalid task types (#9983)
* `/task/user` `GET` endpoint takes plurals of task types as allowed parameters, plus another custom `completedTodos` type * `/tasks/group/:groupId` and `/tasks/challenge/:challengeId` `GET` endpoints task plurals of task types as allowed parameters
This commit is contained in:
committed by
Sabe Jones
parent
b850ea9dbf
commit
4b17f62241
@@ -149,6 +149,8 @@
|
|||||||
"taskAliasAlreadyUsed": "Task alias already used on another task.",
|
"taskAliasAlreadyUsed": "Task alias already used on another task.",
|
||||||
"taskNotFound": "Task not found.",
|
"taskNotFound": "Task not found.",
|
||||||
"invalidTaskType": "Task type must be one of \"habit\", \"daily\", \"todo\", \"reward\".",
|
"invalidTaskType": "Task type must be one of \"habit\", \"daily\", \"todo\", \"reward\".",
|
||||||
|
"invalidTasksType": "Task type must be one of \"habits\", \"dailys\", \"todos\", \"rewards\".",
|
||||||
|
"invalidTasksTypeExtra": "Task type must be one of \"habits\", \"dailys\", \"todos\", \"rewards\", \"completedTodos\".",
|
||||||
"cantDeleteChallengeTasks": "A task belonging to a challenge can't be deleted.",
|
"cantDeleteChallengeTasks": "A task belonging to a challenge can't be deleted.",
|
||||||
"checklistOnlyDailyTodo": "Checklists are supported only on Dailies and To-Dos",
|
"checklistOnlyDailyTodo": "Checklists are supported only on Dailies and To-Dos",
|
||||||
"checklistItemNotFound": "No checklist item was found with given id.",
|
"checklistItemNotFound": "No checklist item was found with given id.",
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ api.getUserTasks = {
|
|||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
let types = Tasks.tasksTypes.map(type => `${type}s`);
|
let types = Tasks.tasksTypes.map(type => `${type}s`);
|
||||||
types.push('completedTodos', '_allCompletedTodos'); // _allCompletedTodos is currently in BETA and is likely to be removed in future
|
types.push('completedTodos', '_allCompletedTodos'); // _allCompletedTodos is currently in BETA and is likely to be removed in future
|
||||||
req.checkQuery('type', res.t('invalidTaskType')).optional().isIn(types);
|
req.checkQuery('type', res.t('invalidTasksTypeExtra')).optional().isIn(types);
|
||||||
|
|
||||||
let validationErrors = req.validationErrors();
|
let validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw validationErrors;
|
if (validationErrors) throw validationErrors;
|
||||||
@@ -325,7 +325,7 @@ api.getChallengeTasks = {
|
|||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
req.checkParams('challengeId', res.t('challengeIdRequired')).notEmpty().isUUID();
|
req.checkParams('challengeId', res.t('challengeIdRequired')).notEmpty().isUUID();
|
||||||
let types = Tasks.tasksTypes.map(type => `${type}s`);
|
let types = Tasks.tasksTypes.map(type => `${type}s`);
|
||||||
req.checkQuery('type', res.t('invalidTaskType')).optional().isIn(types);
|
req.checkQuery('type', res.t('invalidTasksType')).optional().isIn(types);
|
||||||
|
|
||||||
let validationErrors = req.validationErrors();
|
let validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw validationErrors;
|
if (validationErrors) throw validationErrors;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ api.getGroupTasks = {
|
|||||||
middlewares: [authWithHeaders()],
|
middlewares: [authWithHeaders()],
|
||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty().isUUID();
|
req.checkParams('groupId', res.t('groupIdRequired')).notEmpty().isUUID();
|
||||||
req.checkQuery('type', res.t('invalidTaskType')).optional().isIn(types);
|
req.checkQuery('type', res.t('invalidTasksType')).optional().isIn(types);
|
||||||
|
|
||||||
let validationErrors = req.validationErrors();
|
let validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw validationErrors;
|
if (validationErrors) throw validationErrors;
|
||||||
|
|||||||
Reference in New Issue
Block a user