Coder Social home page Coder Social logo

mongoose-i18n-error's Introduction



PyPI Version Testing Status Linting Status Docs Status Contributing Slack

Founding Engineer ๐Ÿค“ @ kumo.ai - PhD from TU Dortmund University

  • ๐Ÿ‘จ๐Ÿผโ€๐Ÿ’ป I love coding and learning new things
  • ๐Ÿคฉ I'm interested in

mongoose-i18n-error's People

Contributors

beaulac avatar rusty1s avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

godness84 beaulac

mongoose-i18n-error's Issues

Exception during parsing unique error of MongoDB

When I insert a duplicated record, Mongo (version 3.4.0) raises this exception:

TypeError: Cannot read property '1' of null\n at parseUniqueError (/app/node_modules/mongoose-i18n-error/index.js:78:17)

In that line of code, mongoose-i18n-error accesses the matches of the regex that it used in order to recover the field name and its value from the error message sent by mongo.

The message that I receive from Mongo is:

E11000 duplicate key error collection: mydb.users index: phone_1 dup key: { : "+3934000001" }

And the current regex is:

var matches = /index:\s..$(.)_1\sdup key:\s{\s:\s"(.*)"\s}/.exec(err.message);

Maybe this version of mongo sends a different error message from what you were expecting.

This regex solves the problem:

var matches = /index:\s(.)_1\sdup key:\s{\s:\s"(.)"\s}/.exec(err.message);

but I don't know if it's always correct in any version of mongo.

Would you mind to take a look?
Thanks

lacks clarity on how to use

i was confused going through the read.me file ; where am I suppose to define this code snippet ?

{
    username: {
        type: 'required',
        message: 'is required',
        value: undefined
    },
    email: {
        type: 'regexp',
        message: 'is no valid email',
        value: 'johndoe.de'
    }
}

it would be very helpful if you had a working example. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.