Skip to content

Commit

Permalink
commented-out start on validation, not sure where to display errors yet
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Jan 15, 2014
1 parent cbfd469 commit ac32edd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ var Image = new Schema({
});

mongoose.model( 'Image', Image );

//Image.schema.path('desc').validate(function (value) {
// example: //return /blue|green|white|red|orange|periwinkle/i.test(value);
//return (value.split(' ').length > 1000);
//}, 'Description must be less than 1000 words');

mongoose.connect( 'mongodb://localhost/infragram' );
4 changes: 4 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ exports.create = function ( req, res ){
src: req.body.src,
updated_at : Date.now(),
}).save( function( err, todo, count ){
// if err, redirect to a filled-out form of the data, with validation errors
// ...i don't yet know how to do this, but here are some relevant things:
//if (err) return handleError(err);
//err.errors.desc.type // <= 'Description must be less than 1000 words'
res.redirect( '/' );
});
};
Expand Down

0 comments on commit ac32edd

Please sign in to comment.