Fixes bug when user attempts to create task with no value field

This commit is contained in:
Rob Scanlon 2013-04-03 22:51:41 -04:00
parent 367ca4a76b
commit 4113eefaf1

View file

@ -87,9 +87,9 @@ validateTask = (req, res, next) ->
unless /^(habit|todo|daily|reward)$/.test type
return res.json 400, err: 'type must be habit, todo, daily, or reward'
text = sanitize(text).xss()
notes = sanitize(notes).xss()
value = sanitize(value).toInt()
newTask.text = sanitize(text).xss()
newTask.notes = sanitize(notes).xss()
newTask.value = sanitize(value).toInt()
switch type
when 'habit'
@ -98,6 +98,8 @@ validateTask = (req, res, next) ->
when 'daily', 'todo'
newTask.completed = false unless typeof completed is 'boolean'
newTask.value = 0 if isNaN newTask.value
_.extend task, newTask
req.task = task
next()