Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmailAddress::ActiveRecordValidator does not work with ActiveStore #99

Open
opensourceame opened this issue Mar 19, 2025 · 0 comments
Open

Comments

@opensourceame
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant