langalex/couch_potato — Issue #47: nested models don't get validated
Author: phoet
Created: 2011-12-06 14:22:50+00:00
State: open

we are currently switching from couchrest_model to couch_potato. while doing this our tests failed because couch_potato is not validating 'nested' models. since this is working with the other framework i am not sure if this complies to the contract of active-model validation or not. i would expect that errors on nested models should also fail the validation of the parent and have their errors collected.

here is an example:

```ruby
class Nested
include CouchPotato::Persistence

property :val
validates :val, :presence => true
end

class Model
include CouchPotato::Persistence

property :val
property :nested, :type => Nested

validates :val, :presence => true
end

m = Model.new
puts m.valid?
puts m.errors.messages
m.nested = Nested.new
puts m.valid?
puts m.errors.messages
puts m.nested.valid?
puts m.nested.errors.messages
m.val = 'name'
puts m.valid?
puts m.errors.messages
puts m.nested.valid?
puts m.nested.errors.messages
```