Reward with negative cost can no longer be created, fixes #11855 (#11870)

* Minor refactoring in scoreTask.js

* Reward value validation added (should be >= 0)
This commit is contained in:
Denys Dorokhov
2020-03-24 13:10:10 +02:00
committed by GitHub
parent 5cf6a67a36
commit 25e72ad907
7 changed files with 128 additions and 37 deletions

View File

@@ -105,7 +105,8 @@ const requiredGroupFields = '_id leader tasksOrder name';
* for "Good habits"-
* @apiParam (Body) {Boolean} [down=true] Only valid for type "habit" If true, enables
* the "-" under "Directions/Action" for "Bad habits"
* @apiParam (Body) {Number} [value=0] Only valid for type "reward." The cost in gold of the reward
* @apiParam (Body) {Number} [value=0] Only valid for type "reward." The cost
* in gold of the reward. Should be greater then or equal to 0.
*
* @apiParamExample {json} Request-Example:
* {
@@ -174,6 +175,8 @@ const requiredGroupFields = '_id leader tasksOrder name';
* underscores and dashes.
* @apiError (400) {BadRequest} Value-ValidationFailed `x` is not a valid enum value
* for path `(body param)`.
* @apiError (400) {BadRequest} Value-ValidationFailed Reward cost should be a
* positive number or 0.`.
* @apiError (401) {NotAuthorized} NoAccount There is no account that uses those credentials.
*
* @apiErrorExample {json} Error-Response: