Module: Floe::ValidationMixin::ClassMethods

Defined in:
lib/floe/validation_mixin.rb

Instance Method Summary collapse

Instance Method Details

#field_error_text(name, field_name, field_value, comment = nil) ⇒ Object



49
50
51
52
53
54
# File 'lib/floe/validation_mixin.rb', line 49

def field_error_text(name, field_name, field_value, comment = nil)
  # instead of displaying a large hash or array, just displaying the word Hash or Array
  field_value = field_value.class if field_value.kind_of?(Hash) || field_value.kind_of?(Array)

  "#{Array(name).join(".")} field \"#{field_name}\"#{" value \"#{field_value}\"" unless field_value.nil?} #{comment}"
end

#invalid_field_error!(name, field_name, field_value, comment) ⇒ Object



45
46
47
# File 'lib/floe/validation_mixin.rb', line 45

def invalid_field_error!(name, field_name, field_value, comment)
  raise Floe::InvalidWorkflowError, field_error_text(name, field_name, field_value, comment)
end

#missing_field_error!(name, field_name) ⇒ Object



41
42
43
# File 'lib/floe/validation_mixin.rb', line 41

def missing_field_error!(name, field_name)
  parser_error!(name, "does not have required field \"#{field_name}\"")
end

#parser_error!(name, comment) ⇒ Object



36
37
38
39
# File 'lib/floe/validation_mixin.rb', line 36

def parser_error!(name, comment)
  name = name.join(".") if name.kind_of?(Array)
  raise Floe::InvalidWorkflowError, "#{name} #{comment}"
end