<commit_before># validates\_url\_format\_of

Rails plugin that provides `validates_url_format_of` to `ActiveRecord` models.

## Usage

After installing the plugin, it's used like

    class User < ActiveRecord::Base
      validates_url_format_of :url,
                              :allow_nil => true,
                              :message => 'is completely unacceptable'
    end
    
Takes the same arguments as [`validates_format_of`](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001052) except for the `:with` regexp.

The default `:message` is different based on whether or not the attribute name contains the word "URL". So you will get "Homepage URL does not appear to be valid" but "Homepage does not appear to be a valid URL" without having to customize the `:message`.

Please note that the regexp used to validate URLs is not perfect, but hopefully good enough. See the test suite. Patches are very welcome.<commit_msg>Mention in README introduction that validation is by regexp.<commit_after># validates\_url\_format\_of

Rails plugin that provides a `validates_url_format_of` method to `ActiveRecord` models. URLs are validated by regexp.

## Usage

After installing the plugin, it's used like

    class User < ActiveRecord::Base
      validates_url_format_of :url,
                              :allow_nil => true,
                              :message => 'is completely unacceptable'
    end
    
Takes the same arguments as [`validates_format_of`](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001052) except for the `:with` regexp.

The default `:message` is different based on whether or not the attribute name contains the word "URL". So you will get "Homepage URL does not appear to be valid" but "Homepage does not appear to be a valid URL" without having to customize the `:message`.

Please note that the regexp used to validate URLs is not perfect, but hopefully good enough. See the test suite. Patches are very welcome.
{'fraction_non_alphanumeric': 0.06951340615690169, 'fraction_numerical': 0.005958291956305859, 'mean_word_length': 3.4579646017699117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2524948', 'n_tokens_mistral': 550, 'n_tokens_neox': 519, 'n_words': 234}