8000 EmailAddress::ActiveRecordValidator does not work with ActiveStore · Issue #99 · afair/email_address · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
EmailAddress::ActiveRecordValidator does not work with ActiveStore #99
Open
@opensourceame

Description

@opensourceame

If you use Active Record Store to store attributes in a serialized field, the ActiveRecordValidator does not work. This is because the validator tries to get the value of the field from accessing it as a hash instead of calling the AR method.

https://github.com/afair/email_address/blob/master/lib/email_address/active_record_validator.rb#L39

Consider this scenario:

class MyClass < ActiveRecord::Base
  self.abstract_class = true
  store_accessor :config
  
  validates_with EmailAddress::ActiveRecordValidator, field: :support_email
end

> a = MyClass.new
> a.support_email = 'invalid email'
> a.support_email
'invalid email'
> a.valid?
true

I made a PR to fix this, in the hopes that someone can review and approve it soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0