How to use mongoose-valid8 - 2 common examples

To help you get started, we’ve selected a few mongoose-valid8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lykmapipo / mongoose-rest-actions / lib / utils.js View on Github external
//build mongoose error
    if (!_.isEmpty(path)) {
      const errors = {};
      _.forEach(path, function (pathName) {
        const props = {
          type: 'unique',
          path: pathName,
          value: _.get(values, pathName),
          message: 'Path `{PATH}` ({VALUE}) is not unique.',
          reason: error.message
        };
        errors[pathName] = new mongoose.Error.ValidatorError(props);
      });

      error = new mongoose.Error.ValidationError();
      error.errors = errors;
    }

    next(error);

  };
github lykmapipo / mongoose-rest-actions / lib / utils.js View on Github external
_.forEach(path, function (pathName) {
        const props = {
          type: 'unique',
          path: pathName,
          value: _.get(values, pathName),
          message: 'Path `{PATH}` ({VALUE}) is not unique.',
          reason: error.message
        };
        errors[pathName] = new mongoose.Error.ValidatorError(props);
      });

mongoose-valid8

Additional mongoose schema validations

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular mongoose-valid8 functions