Class: Sinatra::Validation::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/validation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Result

Returns a new instance of Result.



17
18
19
# File 'lib/sinatra/validation.rb', line 17

def initialize(params)
  @params = params
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



15
16
17
# File 'lib/sinatra/validation.rb', line 15

def messages
  @messages
end

#paramsObject (readonly)

Returns the value of attribute params.



15
16
17
# File 'lib/sinatra/validation.rb', line 15

def params
  @params
end

Instance Method Details

#with_message(errors) ⇒ Object



21
22
23
24
# File 'lib/sinatra/validation.rb', line 21

def with_message(errors)
  @messages = errors.to_h.map { |key, message| "#{key.to_s} #{message.first}" }
  self
end