lotus/validations — pull request #5 by jodosha (2014-08-08 14:11:13+00:00)
Title: Better errors

Improve error reports.

### All the errors

Each error has now a complete set of informations.

```ruby
# from
validator.errors # => { :age => [:size] }

# to
validator.errors # => { :age => [#] }
```

### Single attribute errors

It now hides implementation details `Hash#[]` to `Errors#for`.

```ruby
# from
validator.errors[:age] # => [:size]

# to
validator.errors.for(:age) # => [#]
```

### Iteractions

It now returns a flatten set of `Error` instances, and hides the nested data. It exposes `#each` and `#map`.

```ruby
# from
validator.errors.each do |attribute, errs|
errs.each do |error|
puts error # => :size
end
end

# to
validator.errors.each do |error|
puts error.attribute # => :age
puts error.validation # => :size
puts error.expected # => 18..65
puts error.actual # => 15
end
```

### Adding errors

Again, it hides implementation data: `Hash` and `Array`.

```ruby
# from
validator.errors[:age].push(:size)

# to
validator.errors.add(:age, :size, 18..65, 17)
```

### Counts

It returns the count of the flatten errors, via `#count` or `#size`.

```ruby
# from
validator.errors.values.flatten.count # => 3

# to
validator.errors.count # => 3
```
Closes #3