constructor(instance) {
    let _message;
    if (getConstructorName(instance) === 'model') {
      _message = instance.constructor.modelName + ' validation failed';
    } else {
      _message = 'Validation failed';
    }

    super(_message);

    this.errors = {};
    this._message = _message;

    if (instance) {
      instance.$errors = this.errors;
    }
  }
Document Validation Error

@api private
@param {Document} [instance]
@inherits MongooseError