File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -15,4 +15,10 @@ var Image = new Schema({
15
15
} ) ;
16
16
17
17
mongoose . 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
+
18
24
mongoose . connect ( 'mongodb://localhost/infragram' ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ exports.create = function ( req, res ){
53
53
src : req . body . src ,
54
54
updated_at : Date . now ( ) ,
55
55
} ) . 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'
56
60
res . redirect ( '/' ) ;
57
61
} ) ;
58
62
} ;
You can’t perform that action at this time.
0 commit comments