<commit_before>Active Model Validator
============================

This is a ActiveModel validators for domains and ip addresses.

Installation
------------
    gem install validator

Usage
-------

In your models, the gem provides new validators like :domain or :ip_address

    class Model < ActiveRecord::Base
      validates :domain_name, :domain => true
      validates :ip, :ip_address => true
    end


Domain Validator
----------------

    validates :domain_name, :domain => true

    validates :domain_name, :domain => {:message => 'custom message'}

    # custom full domain length and label length
    validates :domain_name, :domain => { :length => 200, :label_length => 60 }


Ip Address Validator
--------------------

    # validate ip address
    validates :ip, :ip_address => true

    # ip address allowed with prefix
    validates :ip, :ip_address => { :allow_prefix => true }

    # allows only IPv4
    validates :ip, :ip_address => { :only => :ipv4 }

    # allows only IPv6
    validates :ip, :ip_address => { :only => :ipv6 }

    validates :ip, :ip_address => { :message => "custom message" }


Localization Tricks
-------------------
To customize error message, you can use { :message => "your custom message" } or simple use Rails localization en.yml file, for instance:

    en:
      errors:
        messages:
          domain:
            length: "your custom length error message"
         ip_address:
           invalid:
             general: "your custom invalid ip address error message"


Copyright
---------

Copyright (c) 2011 <NAME>. See LICENSE for details.<commit_msg>Added localization tricks for models<commit_after>Active Model Validator
============================

This is a ActiveModel validators for domains and ip addresses.

Installation
------------
    gem install validator

Usage
-------

In your models, the gem provides new validators like :domain or :ip_address

    class Model < ActiveRecord::Base
      validates :domain_name, :domain => true
      validates :ip, :ip_address => true
    end


Domain Validator
----------------

    validates :domain_name, :domain => true

    validates :domain_name, :domain => {:message => 'custom message'}

    # custom full domain length and label length
    validates :domain_name, :domain => { :length => 200, :label_length => 60 }


Ip Address Validator
--------------------

    # validate ip address
    validates :ip, :ip_address => true

    # ip address allowed with prefix
    validates :ip, :ip_address => { :allow_prefix => true }

    # allows only IPv4
    validates :ip, :ip_address => { :only => :ipv4 }

    # allows only IPv6
    validates :ip, :ip_address => { :only => :ipv6 }

    validates :ip, :ip_address => { :message => "custom message" }


Localization Tricks
-------------------
To customize error message, you can use { :message => "your custom message" } or simple use Rails localization en.yml file, for instance:

    en:
      errors:
        messages:
          domain:
            length: "your custom length error message"
         ip_address:
           invalid:
             general: "your custom invalid ip address error message"
      activemodel:
        errors:
          messages:
            domain:
              invalid: "custom error message only for activemodel"
           models:
             your_model:
               domain:
                 invalid: "custom error message for YourDomain model"


Copyright
---------

Copyright (c) 2011 <NAME>. See LICENSE for details.
{'fraction_non_alphanumeric': 0.14281658148779103, 'fraction_numerical': 0.0073821692220329355, 'mean_word_length': 2.336174242424242, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, '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': '5274118', 'n_tokens_mistral': 960, 'n_tokens_neox': 902, 'n_words': 346}