Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions lib/routes/api/v2/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ var canCreateProject = function(req, res, next){

};

var validateProject = function(project) {
if (!project.title){
return { error: "title_required" };
}

if (!project.description){
return { error: "description_required" };
}
}

var createProject = function(req, res, next){

if(req.body.link && req.body.link.indexOf('http') != 0) {
Expand All @@ -103,12 +113,9 @@ var createProject = function(req, res, next){
, domain: req.body.domain
});

if (!project.title){
return res.json(500, { error: "title_required" });
}

if (!project.description){
return res.json(500, { error: "description_required" });
var err = validateProject(project);
if (err) {
return res.json(500, err);
}

project.save(function(err, project){
Expand Down Expand Up @@ -180,12 +187,9 @@ var updateProject = function(req, res, next) {

//add trim

if (!project.title){
return res.json(500, { error: "title_required" });
}

if (!project.description){
return res.json(500, { error: "description_required" });
var err = validateProject(project);
if (err) {
return res.json(500, err);
}

project.save(function(err, project){
Expand Down