Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including mongoose-ember-errors with all npm packages installed. Try it out:

var mongooseEmberErrors = require("mongoose-ember-errors")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mongoose-ember-errors v0.0.5

Convert mongoose validation errors to ember-data compatible errors

Mongoose Ember Errors

Simple tool to convert Mongoose's ValidationError into Ember-Data compatible.


npm install mongoose-ember-errors --save


var EmberErrors = require('mongoose-ember-errors'); {
  // err contains normal ValidationError
  err = new EmberErrors(err);

The conversion looks similar to this:

{ [ValidationError: Schema validation failed]
  message: 'Schema validation failed',
  name: 'ValidationError',
   { testObjectId:
      { [CastError: Cast to ObjectID failed for value "test" at path "testObjectId"]
        message: 'Cast to ObjectID failed for value "test" at path "testObjectId"',
        name: 'CastError',
        kind: 'ObjectID',
        value: 'test',
        path: 'testObjectId' },
      { [ValidatorError: Path `testField` is required.]
        properties: [Object],
        message: 'Path `testField` is required.',
        name: 'ValidatorError',
        kind: 'required',
        path: 'testField',
        value: undefined } } }


{ [Error: Schema validation failed]
  message: 'Schema validation failed',
   { testObjectId: [ 'test is invalid' ],
     testField: [ 'Path `testField` is required.' ] } }
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free