Module: BRS::Validation

Defined in:
lib/brs/validation.rb

Class Method Summary collapse

Class Method Details

.validate_bool(value) ⇒ Object

Raises:



8
9
10
# File 'lib/brs/validation.rb', line 8

def self.validate_bool(value)
  raise ValidateError, "invalid bool" unless value.is_a?(::TrueClass) || value.is_a?(::FalseClass)
end

.validate_hash(value) ⇒ Object

Raises:



32
33
34
# File 'lib/brs/validation.rb', line 32

def self.validate_hash(value)
  raise ValidateError, "invalid hash" unless value.is_a? ::Hash
end

.validate_io(value) ⇒ Object

Raises:



28
29
30
# File 'lib/brs/validation.rb', line 28

def self.validate_io(value)
  raise ValidateError, "invalid io" unless value.is_a? ::IO
end

.validate_not_negative_integer(value) ⇒ Object

Raises:



16
17
18
# File 'lib/brs/validation.rb', line 16

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) ⇒ Object

Raises:



12
13
14
# File 'lib/brs/validation.rb', line 12

def self.validate_positive_integer(value)
  raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value > 0
end

.validate_proc(value) ⇒ Object

Raises:



36
37
38
# File 'lib/brs/validation.rb', line 36

def self.validate_proc(value)
  raise ValidateError, "invalid proc" unless value.is_a?(::Proc) || value.is_a?(::Method) || value.is_a?(::UnboundMethod)
end

.validate_string(value) ⇒ Object

Raises:



20
21
22
# File 'lib/brs/validation.rb', line 20

def self.validate_string(value)
  raise ValidateError, "invalid string" unless value.is_a? ::String
end

.validate_symbol(value) ⇒ Object

Raises:



24
25
26
# File 'lib/brs/validation.rb', line 24

def self.validate_symbol(value)
  raise ValidateError, "invalid symbol" unless value.is_a? ::Symbol
end