File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,4 +15,10 @@ var Image = new Schema({
1515} ) ;
1616
1717mongoose . model ( 'Image' , Image ) ;
18+
19+ //Image.schema.path('desc').validate(function (value) {
20+ // example: //return /blue|green|white|red|orange|periwinkle/i.test(value);
21+ //return (value.split(' ').length > 1000);
22+ //}, 'Description must be less than 1000 words');
23+
1824mongoose . connect ( 'mongodb://localhost/infragram' ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ exports.create = function ( req, res ){
5353 src : req . body . src ,
5454 updated_at : Date . now ( ) ,
5555 } ) . save ( function ( err , todo , count ) {
56+ // if err, redirect to a filled-out form of the data, with validation errors
57+ // ...i don't yet know how to do this, but here are some relevant things:
58+ //if (err) return handleError(err);
59+ //err.errors.desc.type // <= 'Description must be less than 1000 words'
5660 res . redirect ( '/' ) ;
5761 } ) ;
5862} ;
You can’t perform that action at this time.
0 commit comments