Module: Riffer::Helpers::Validations

Included in:
Agent
Defined in:
lib/riffer/helpers/validations.rb

Overview

Helper module for input validation.

Instance Method Summary collapse

Instance Method Details

#validate_is_string!(value, name = "value") ⇒ Object

Validates that a value is a non-empty string.

value

Object - the value to validate

name

String - the name of the value for error messages

Returns true if valid.

Raises Riffer::ArgumentError if the value is not a string or is empty.



13
14
15
16
17
18
# File 'lib/riffer/helpers/validations.rb', line 13

def validate_is_string!(value, name = "value")
  raise Riffer::ArgumentError, "#{name} must be a String" unless value.is_a?(String)
  raise Riffer::ArgumentError, "#{name} cannot be empty" if value.strip.empty?

  true
end