Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded documents validation using model validation #88

Closed
quentin-sommer opened this issue Jun 1, 2016 · 1 comment · Fixed by #87
Closed

Embedded documents validation using model validation #88

quentin-sommer opened this issue Jun 1, 2016 · 1 comment · Fixed by #87

Comments

@quentin-sommer
Copy link

Hi,

using mongoose model validation on embedded documents the error printed is in form of [object Object] (I guess because it's a nested error object for the sub-doc ?), How could I make sure it gets entirely serialized ?

// main document schema
const userSchema = new Schema({
  email: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true
  },
  subDoc: [sub]
});

// sub document schema
const subDoc = new Schema({
  username: {
    type: String,
  }
});
@daffl
Copy link
Member

daffl commented Jun 16, 2016

I just verified that it sends the entire error. If you are just console.loging the error you might want to try console.log(JSON.stringify(error.toJSON())).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants