class Sensu::API::Validators::Check

Public Instance Methods

valid?(check) click to toggle source

Determine if a check definition is valid.

@param check [Hash] @return [TrueClass, FalseClass]

# File lib/sensu/api/validators/check.rb, line 37
def valid?(check)
  validate_check_result(check)
  true
rescue Invalid
  false
end
validate_check_result(check) click to toggle source

Validate a check result, selectively using check definition validation methods.

@param check [Hash]

# File lib/sensu/api/validators/check.rb, line 17
def validate_check_result(check)
  must_be_a_string(check[:output]) ||
    invalid(check, "check output must be a string")
  must_be_an_integer(check[:status]) ||
    invalid(check, "check status must be an integer")
  must_be_an_integer(check[:executed]) ||
    invalid(check, "check executed timestamp must be an integer")
  validate_check_name(check)
  validate_check_handling(check)
  validate_check_aggregate(check)
  validate_check_flap_detection(check)
  validate_check_truncate_output(check)
  validate_check_source(check) if check[:source]
  validate_check_ttl(check) if check[:ttl]
end

Private Instance Methods

invalid(*arguments) click to toggle source

This method is called when validation methods encounter an invalid definition object. This method raises an exception to be caught by `valid?()`.

# File lib/sensu/api/validators/check.rb, line 49
def invalid(*arguments)
  raise Invalid
end