Validations are triggered and work as expected for attributes of the record I'm passing in (i.e required(:title).filled
), but not for attributes of nested models (i.e required(:name).filled
in artist
).
class AlbumForm < Reform::Form
property :title
validation do
required(:title).filled
end
property :artist do
property :name
validation do
required(:name).filled
end
end
end
(Snippet taken from http://trailblazer.to/gems/reform)
I expect Albumform.new(album).valid?
to return false if album.artist.name == nil
but it does not. What am I missing here? How can this be achieved?
Using:
- rails 4.2.7.1
- reform-rails 0.1.7
- reform 2.2.2
- dry-validation 0.10.3