Factlink/pavlov — pull request #57 by marten (2013-08-13 15:21:49+00:00)
Title: Validations via ActiveModel::Errors (work-in-progress)

This is a rough first spike.

The user must end her `valid?` method with `errors.empty?` or otherwise a false value will be returned if the last check was fine (`errors.add(:title, 'must mention pavlov') unless title =~ /pavlov/` returns nil if the title mentions Pavlov).

Therefore, it would be better if the user implemented some other method, and `valid?` would be a library method that simply returns `errors.empty?` That `valid?` method should probably be public now, since we want to check validity before calling operations.

A sensible name for the method that the user should implement would be `validate`, but that's already taken by a method that would possibly be better named `check_validation` (since it's similar to `check_authorization`).

The names of various methods could ideally be cleaned up, but that's hard to do backwards-compatibly. For consistent naming, the user should have to implement `validate`, `authorize`, `execute`. But that means swapping the meaning of `validate` and `valid?` with respect to the current way.

But replacing `def valid?` with `def validate` might not be such a big deal.

In summary: I'd love some feedback on how we could do this while maintaining a smooth upgrade path.