easiest way to skip validations for a document

13 views
Skip to first unread message

madhums

unread,
May 17, 2013, 3:04:47 PM5/17/13
to mongoo...@googlegroups.com
What is the easiest way to skip validations for a document?

UserSchema.path('name').validate(function (name) {
  if (this.noValidation) return true
  return name.trim().length
}, 'Please provide a valid name')

var user = new User({ email: 'j...@example.com' })

// user.skipValidation = true // something like this
user.save(function (err) {
  // err is null
})


Reply all
Reply to author
Forward
0 new messages