mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Improved number validation (#11131)
* fix(purchasing): more number validation * test(purchasing): add error cases Also refactor NaN check and create client mixin * fix(purchasing): cover "purchase" cases
This commit is contained in:
@@ -73,7 +73,7 @@ module.exports = function purchase (user, req = {}, analytics) {
|
||||
let key = get(req.params, 'key');
|
||||
|
||||
let quantity = req.quantity ? Number(req.quantity) : 1;
|
||||
if (isNaN(quantity)) throw new BadRequest(i18n.t('invalidQuantity', req.language));
|
||||
if (quantity < 1 || !Number.isInteger(quantity)) throw new BadRequest(i18n.t('invalidQuantity', req.language));
|
||||
|
||||
if (!type) {
|
||||
throw new BadRequest(i18n.t('typeRequired', req.language));
|
||||
|
||||
Reference in New Issue
Block a user