Class: OSTSdk::Util::CommonValidator
- Inherits:
-
Object
- Object
- OSTSdk::Util::CommonValidator
- Defined in:
- lib/ost-sdk-ruby/util/common_validator.rb
Constant Summary collapse
- REGEX_FOR_UUID =
/\A[0-9a-z\.\-]+\z/i
Class Method Summary collapse
-
.is_a_hash?(obj) ⇒ Boolean
Is the given object Hash.
-
.is_boolean?(object) ⇒ Boolean
Arguments: object: (Boolean).
-
.is_numeric?(object) ⇒ Boolean
Check for numeric-ness of an input.
-
.is_valid_uuid_format?(value) ⇒ Boolean
Is the value is valid for given key.
Class Method Details
.is_a_hash?(obj) ⇒ Boolean
Is the given object Hash
Arguments:
object: (Hash)
Returns:
Boolean
44 45 46 |
# File 'lib/ost-sdk-ruby/util/common_validator.rb', line 44 def self.is_a_hash?(obj) obj.is_a?(Hash) || obj.is_a?(ActionController::Parameters) end |
.is_boolean?(object) ⇒ Boolean
Arguments:
object: (Boolean)
Returns:
Boolean
29 30 31 32 33 34 |
# File 'lib/ost-sdk-ruby/util/common_validator.rb', line 29 def self.is_boolean?(object) [ true, false ].include?(object) end |
.is_numeric?(object) ⇒ Boolean
Check for numeric-ness of an input
Arguments:
object: (Float)
Returns:
Boolean
17 18 19 |
# File 'lib/ost-sdk-ruby/util/common_validator.rb', line 17 def self.is_numeric?(object) true if Float(object) rescue false end |
.is_valid_uuid_format?(value) ⇒ Boolean
Is the value is valid for given key
Arguments:
object: (String)
Returns:
Boolean
56 57 58 |
# File 'lib/ost-sdk-ruby/util/common_validator.rb', line 56 def self.is_valid_uuid_format?(value) value =~ REGEX_FOR_UUID end |