Class: ADSP::Validation
- Inherits:
-
Object
- Object
- ADSP::Validation
- Defined in:
- lib/adsp/validation.rb
Overview
ADSP::Validation class.
Class Method Summary collapse
-
.validate_array(value) ⇒ Object
Raises error when
value
is not array. -
.validate_hash(value) ⇒ Object
Raises error when
value
is not hash. -
.validate_not_negative_integer(value) ⇒ Object
Raises error when
value
is not negative integer. -
.validate_positive_integer(value) ⇒ Object
Raises error when
value
is not positive integer. -
.validate_proc(value) ⇒ Object
Raises error when
value
is not proc. -
.validate_string(value) ⇒ Object
Raises error when
value
is not string. -
.validate_symbol(value) ⇒ Object
Raises error when
value
is not symbol.
Class Method Details
.validate_array(value) ⇒ Object
Raises error when value
is not array.
10 11 12 |
# 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) ⇒ Object
Raises error when value
is not hash.
15 16 17 |
# 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) ⇒ Object
Raises error when value
is not negative integer.
20 21 22 |
# 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) ⇒ Object
Raises error when value
is not positive integer.
25 26 27 |
# 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) ⇒ Object
Raises error when value
is not proc.
30 31 32 33 34 |
# 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) ⇒ Object
Raises error when value
is not string.
37 38 39 |
# 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) ⇒ Object
Raises error when value
is not symbol.
42 43 44 |
# File 'lib/adsp/validation.rb', line 42 def self.validate_symbol(value) raise ValidateError, "invalid symbol" unless value.is_a? ::Symbol end |