Class: MicroValidator::Errors

Inherits:
Object
  • Object
show all
Defined in:
lib/micro_validator/errors.rb

Instance Method Summary collapse

Instance Method Details

#add(attribute, message) ⇒ Object



3
4
5
6
# File 'lib/micro_validator/errors.rb', line 3

def add(attribute, message)
  errors[attribute] ||= []
  errors[attribute] << message
end

#allObject



16
17
18
# File 'lib/micro_validator/errors.rb', line 16

def all
  @errors
end

#clearObject



8
9
10
# File 'lib/micro_validator/errors.rb', line 8

def clear
  @errors = {}
end

#empty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/micro_validator/errors.rb', line 12

def empty?
  errors.empty?
end

#field(name) ⇒ Object



20
21
22
# File 'lib/micro_validator/errors.rb', line 20

def field(name)
  @errors[name]
end