validates_hostname icon indicating copy to clipboard operation
validates_hostname copied to clipboard

Calling ActiveRecord::Base.send(:include, PAK::ValidatesHostname) has side effects

Open pgouv opened this issue 7 years ago • 6 comments

I was wondering why Rails.application.config.active_record.belongs_to_required_by_default was not working and this gem is the culprit. I am wondering whether there is a fix for this.

pgouv avatar Feb 15 '18 11:02 pgouv

I have not been working with Rails for ages and currently do not have a lot of time on my hands. Any help fixing this issue would be much appreciated.

KimNorgaard avatar Feb 19 '18 07:02 KimNorgaard

@KimNorgaard I'm interested in adopting this gem. I keep having the need to do domain validation in Rails and this is the best validator I've found.

Features I'd like to add:

  • label validator
  • option to restrict by number of labels (ie. foo.com vs www.foo.com)
  • look into using PublicSuffix
  • disallow local and private IPs and hosts (example.com, localhost, 127.0.0.1, etc)

schwern avatar Feb 17 '20 23:02 schwern

Thank you for reaching out and offering help. I'm still a bit pressed on time but I'm willing to give you a commit bit and assist with pushing to rubygems when we have a stable version.

KimNorgaard avatar Feb 18 '20 12:02 KimNorgaard

I just pushed v1.0.10 with the bugfix from #13 to rubygems. Since your changes are breaking backwards compatibility I'd like to move to wards v1.1.0 or possibly v2.0.0. What are your thoughts?

KimNorgaard avatar Feb 18 '20 12:02 KimNorgaard

Thanks! I only have a couple years of Ruby experience, and this is my first time messing with a gem. I cribbed from another validation gem. I do have a lot of experience releasing Perl modules.

Yes, v2.0.0 makes sense if we're breaking backwards compatibility and following semantic versioning. If you have any other compatibility breaking changes you'd like to make while we're at it, perhaps you can write them up as issues and I can have a look.

schwern avatar Feb 26 '20 00:02 schwern

My experience with releasing gems is also limited to this one, so I guess we are in the same boat. It's a pretty simple validator and I don't expect it to change much since it's pretty much based off the RFCs and they also don't change much. I don't have any big plans for a v2.

I once thought about doing something clever with the ALLOWED_TLDS list, specifically making it always updated, but the only way that would work would be fetching the list runtime which I'm against for obvious reasons. For now I've just updated it by hand periodically and bumped the version. I guess that suffices for most people.

KimNorgaard avatar Feb 26 '20 11:02 KimNorgaard