Module: Mongoid::Config::Validators::Client

Extended by:
Client
Included in:
Client
Defined in:
build/mongoid-7.3/lib/mongoid/config/validators/client.rb

Overview

Validator for client specific configuration.

Constant Summary collapse

STANDARD =

Standard configuration options.

Since:

  • 3.0.0

[ :database, :hosts, :username, :password ].freeze

Instance Method Summary collapse

Instance Method Details

#validate(clients) ⇒ Object

Validate the client configuration.

Examples:

Validate the client config.

Client.validate({ default: { hosts: [ "localhost:27017" ] }})

Parameters:

  • clients (Hash)

    The clients config.

Since:

  • 3.0.0



25
26
27
28
29
30
31
32
33
34
# File 'build/mongoid-7.3/lib/mongoid/config/validators/client.rb', line 25

def validate(clients)
  unless clients.has_key?(:default)
    raise Errors::NoDefaultClient.new(clients.keys)
  end
  clients.each_pair do |name, config|
    validate_client_database(name, config)
    validate_client_hosts(name, config)
    validate_client_uri(name, config)
  end
end