lib/operations/db_ops.js
function validateDatabaseName(databaseName) {
  if (typeof databaseName !== 'string')
    throw MongoError.create({ message: 'database name must be a string', driver: true });
  if (databaseName.length === 0)
    throw MongoError.create({ message: 'database name cannot be the empty string', driver: true });
  if (databaseName === '$external') return;

  const invalidChars = [' ', '.', '$', '/', '\\'];
  for (let i = 0; i < invalidChars.length; i++) {
    if (databaseName.indexOf(invalidChars[i]) !== -1)
      throw MongoError.create({
        message: "database names cannot contain the character '" + invalidChars[i] + "'",
        driver: true
      });
  }
}
function validateDatabaseName(databaseName) {
  if (typeof databaseName !== 'string')
    throw MongoError.create({ message: 'database name must be a string', driver: true });
  if (databaseName.length === 0)
    throw MongoError.create({ message: 'database name cannot be the empty string', driver: true });
  if (databaseName === '$external') return;

  const invalidChars = [' ', '.', '$', '/', '\\'];
  for (let i = 0; i < invalidChars.length; i++) {
    if (databaseName.indexOf(invalidChars[i]) !== -1)
      throw MongoError.create({
        message: "database names cannot contain the character '" + invalidChars[i] + "'",
        driver: true
      });
  }
}
function validateDatabaseName ( databaseName ) { if ( typeof databaseName !== 'string' ) throw MongoError . create ( { message : 'database name must be a string' , driver : true } ) ; if ( databaseName . length === 0 ) throw MongoError . create ( { message : 'database name cannot be the empty string' , driver : true } ) ; if ( databaseName === '$external' ) return ; const invalidChars = [ ' ' , '.' , '$' , '/' , '\\' ] ; for ( let i = 0 ; i < invalidChars . length ; i ++ ) { if ( databaseName . indexOf ( invalidChars [ i ] ) !== - 1 ) throw MongoError . create ( { message : "database names cannot contain the character '" + invalidChars [ i ] + "'" , driver : true } ) ; } }
Validate the database name
Validate the database name