class Airbrake::Config::Validator
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/airbrake-ruby/config/validator.rbs class Airbrake::Config::Validator def check_notify_ability: (Airbrake::Config config) -> Airbrake::Promise def ignored_environment?: (Airbrake::Config config) -> untyped def valid_environment?: (Airbrake::Config config) -> untyped def valid_project_id?: (Airbrake::Config config) -> true def valid_project_key?: (Airbrake::Config config) -> true def validate: (Airbrake::Config config) -> Airbrake::Promise end
@since v1.5.0
@api private
configuration.
is a config that guarantees that data can be sent to Airbrake given its
Validator validates values of {Airbrake::Config} options. A valid config
def check_notify_ability(config)
Experimental RBS support (using type sampling data from the type_fusion
project).
def check_notify_ability: (Airbrake::Config config) -> Airbrake::Promise
This signature was generated using 6 samples from 1 application.
- Since: - v4.1.0
Parameters:
-
config
(Airbrake::Config
) --
def check_notify_ability(config) promise = Airbrake::Promise.new unless config.error_notifications return promise.reject('error notifications are disabled') end if ignored_environment?(config) return promise.reject( "current environment '#{config.environment}' is ignored", ) end promise.resolve(:ok) end
def ignored_environment?(config)
Experimental RBS support (using type sampling data from the type_fusion
project).
def ignored_environment?: (Airbrake::Config config) -> untyped
This signature was generated using 5 samples from 1 application.
def ignored_environment?(config) if config.ignore_environments.any? && config.environment.nil? config.logger.warn( "#{LOG_LABEL} the 'environment' option is not set, " \ "'ignore_environments' has no effect", ) end return false if config.ignore_environments.none? || !config.environment env = config.environment.to_s config.ignore_environments.any? do |pattern| pattern.is_a?(Regexp) ? env.match(pattern) : env == pattern.to_s end end
def valid_environment?(config)
Experimental RBS support (using type sampling data from the type_fusion
project).
def valid_environment?: (Airbrake::Config config) -> untyped
This signature was generated using 4 samples from 1 application.
def valid_environment?(config) VALID_ENV_TYPES.any? { |type| config.environment.is_a?(type) } end
def valid_project_id?(config)
Experimental RBS support (using type sampling data from the type_fusion
project).
def valid_project_id?: (Airbrake::Config config) -> true
This signature was generated using 9 samples from 1 application.
def valid_project_id?(config) return true if config.project_id.to_i > 0 false end
def valid_project_key?(config)
Experimental RBS support (using type sampling data from the type_fusion
project).
def valid_project_key?: (Airbrake::Config config) -> true
This signature was generated using 5 samples from 1 application.
def valid_project_key?(config) return false unless config.project_key.is_a?(String) return false if config.project_key.empty? true end
def validate(config)
Experimental RBS support (using type sampling data from the type_fusion
project).
def validate: (Airbrake::Config config) -> Airbrake::Promise
This signature was generated using 8 samples from 1 application.
- Since: - v4.1.0
Parameters:
-
config
(Airbrake::Config
) --
def validate(config) promise = Airbrake::Promise.new unless valid_project_id?(config) return promise.reject(':project_id is required') end unless valid_project_key?(config) return promise.reject(':project_key is required') end unless valid_environment?(config) return promise.reject( "the 'environment' option must be configured " \ "with a Symbol (or String), but '#{config.environment.class}' was " \ "provided: #{config.environment}", ) end promise.resolve(:ok) end