SchemeString, precedence of uppercase and match

97 views
Skip to first unread message

Ka Yuk LEE

unread,
May 18, 2013, 8:40:32 AM5/18/13
to mongoo...@googlegroups.com

I would like to add a gender field which accepts [MmFf] and normalizes to [MF]. Here's my schema:

var UserSchema = new Schema({
    name: String
    gender : { type: String, upper: true, match: /[MmFf]/ }
});

I wonder what's the sequence of execution of the SchemeString functions. If uppercase is executed beforematch, my match could as well be [MF].

I also have similar question concerning trim and match.

Thanks.

Aaron Heckmann

unread,
May 20, 2013, 5:04:28 PM5/20/13
to mongoo...@googlegroups.com
upper and trim are setters - when the value is assigned it is modified.

match is a validator - executed later when calling .validate() or .save()


--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron


Ka Yuk LEE

unread,
May 20, 2013, 10:03:31 PM5/20/13
to mongoo...@googlegroups.com

Thanks for the pointer.

You received this message because you are subscribed to a topic in the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongoose-orm/L5ztQDFbBWU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mongoose-orm...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages