class ADSP::Validation

ADSP::Validation class.

Public Class Methods

validate_array(value) click to toggle source

Raises error when value is not array.

# File lib/adsp/validation.rb, line 10
def self.validate_array(value)
  raise ValidateError, "invalid array" unless value.is_a? ::Array
end
validate_hash(value) click to toggle source

Raises error when value is not hash.

# File lib/adsp/validation.rb, line 15
def self.validate_hash(value)
  raise ValidateError, "invalid hash" unless value.is_a? ::Hash
end
validate_not_negative_integer(value) click to toggle source

Raises error when value is not negative integer.

# File lib/adsp/validation.rb, line 20
def self.validate_not_negative_integer(value)
  raise ValidateError, "invalid not negative integer" unless value.is_a?(::Integer) && value >= 0
end
validate_positive_integer(value) click to toggle source

Raises error when value is not positive integer.

# File lib/adsp/validation.rb, line 25
def self.validate_positive_integer(value)
  raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value.positive?
end
validate_proc(value) click to toggle source

Raises error when value is not proc.

# File lib/adsp/validation.rb, line 30
def self.validate_proc(value)
  unless value.is_a?(::Proc) || value.is_a?(::Method) || value.is_a?(::UnboundMethod)
    raise ValidateError, "invalid proc"
  end
end
validate_string(value) click to toggle source

Raises error when value is not string.

# File lib/adsp/validation.rb, line 37
def self.validate_string(value)
  raise ValidateError, "invalid string" unless value.is_a? ::String
end
validate_symbol(value) click to toggle source

Raises error when value is not symbol.

# File lib/adsp/validation.rb, line 42
def self.validate_symbol(value)
  raise ValidateError, "invalid symbol" unless value.is_a? ::Symbol
end