makandra / active_type

Make any Ruby object quack like ActiveRecord
MIT License
1.09k stars 74 forks source link

NotImplementedError when checking for uniqueness #90

Closed Ichaelus closed 7 years ago

Ichaelus commented 7 years ago

The following class raises a NotImplementedError:

class User::SignUp < ActiveType::Object
  attribute :email, :string
  validates :email, uniqueness: true
end

The same error occurs when setting uniqueness to {case_sensitive: false}.

Best, Michael

foobear commented 7 years ago

ActiveType::Object is not backed by a database record, so it can't validate uniqueness.

It looks like you want to define a form model. If you inherit from ActiveType::Record[User] (which should have an email attribute, so you should omit attribute :email in the form model), everything should be fine. :)