Socket
Book a DemoInstallSign in
Socket

@gorebel/mongoose-ember-errors

Package Overview
Dependencies
Maintainers
8
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gorebel/mongoose-ember-errors

Convert mongoose validation errors to ember-data compatible errors

0.1.0
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
8
Weekly downloads
 
Created
Source

Mongoose Ember Errors

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

Install

npm install mongoose-ember-errors --save

Usage

var EmberErrors = require('mongoose-ember-errors');

model.save(function(err) {
  // err contains normal ValidationError
  err = new EmberErrors(err);
});

The conversion looks similar to this:

{ [ValidationError: Schema validation failed]
  message: 'Schema validation failed',
  name: 'ValidationError',
  errors:
   { 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' },
     testField:
      { [ValidatorError: Path `testField` is required.]
        properties: [Object],
        message: 'Path `testField` is required.',
        name: 'ValidatorError',
        kind: 'required',
        path: 'testField',
        value: undefined } } }

Into:

{ [Error: Schema validation failed]
  message: 'Schema validation failed',
  errors:
   { testObjectId: [ 'test is invalid' ],
     testField: [ 'Path `testField` is required.' ] } }

Keywords

ember

FAQs

Package last updated on 25 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.