email_format_validator 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -2
- data/email_format_validator.gemspec +1 -1
- data/lib/email_format_validator.rb +1 -1
- data/test/email_format_validator_test.rb +3 -3
- metadata +4 -4
    
        data/README.md
    CHANGED
    
    | @@ -22,9 +22,18 @@ You can turn on RFC 822 compliant email verification by passing on: | |
| 22 22 |  | 
| 23 23 | 
             
            Be aware that this is disabled by default as websites will often need a less permissive email check than the RFC one (check out tests for more details).
         | 
| 24 24 |  | 
| 25 | 
            -
            You can also modify the default message if validation fails:
         | 
| 25 | 
            +
            You can also modify the default message ("is improperly formatted") if validation fails:
         | 
| 26 26 |  | 
| 27 | 
            -
                validates :email, :email_format => { :message => "is not formatted | 
| 27 | 
            +
                validates :email, :email_format => { :message => "is not well formatted" }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            I18n
         | 
| 30 | 
            +
            ----
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            If you use I18n, the default key to translate is :improperly_formatted. So if you add to your User model:
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                validates :email, :email_format => true
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            You can translate (or overload) the default message via for e.g. (in english): "en.activerecord.errors.models.user.attributes.email.improperly_formatted"
         | 
| 28 37 |  | 
| 29 38 | 
             
            Tests
         | 
| 30 39 | 
             
            -----
         | 
| @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) | |
| 3 3 |  | 
| 4 4 | 
             
            Gem::Specification.new do |s|
         | 
| 5 5 | 
             
              s.name        = "email_format_validator"
         | 
| 6 | 
            -
              s.version     = "1.0. | 
| 6 | 
            +
              s.version     = "1.0.1"
         | 
| 7 7 | 
             
              s.authors     = ["Axel Vergult"]
         | 
| 8 8 | 
             
              s.email       = ["axel.vergult@gmail.com"]
         | 
| 9 9 | 
             
              s.homepage    = "https://github.com/episko/email_format_validator"
         | 
| @@ -23,7 +23,7 @@ class EmailFormatValidator < ActiveModel::EachValidator | |
| 23 23 | 
             
              def validate_each(record, attribute, value)
         | 
| 24 24 | 
             
                pattern_choosed = options[:rfc] ? Patterns::EMAIL : Patterns::LESS_RFC_COMPLIANT_EMAIL
         | 
| 25 25 | 
             
                unless value =~ pattern_choosed
         | 
| 26 | 
            -
                  record.errors.add(attribute, options[:message] || : | 
| 26 | 
            +
                  record.errors.add(attribute, options[:message] || I18n.t(:improperly_formatted, :default => "is improperly formatted"))
         | 
| 27 27 | 
             
                end
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| @@ -19,7 +19,7 @@ class TestUserAllowsNilToFalse < TestModel | |
| 19 19 | 
             
            end
         | 
| 20 20 |  | 
| 21 21 | 
             
            class TestUserWithMessage < TestModel
         | 
| 22 | 
            -
              validates :email, :email_format => { :message => 'is not formatted | 
| 22 | 
            +
              validates :email, :email_format => { :message => 'is not well formatted' }
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 25 | 
             
            class TestEmailFormatValidator < MiniTest::Unit::TestCase
         | 
| @@ -172,13 +172,13 @@ class TestEmailFormatValidator < MiniTest::Unit::TestCase | |
| 172 172 | 
             
              def test_default_message_on_error
         | 
| 173 173 | 
             
                test_user = TestUser.new(:email => "invalid_email@")
         | 
| 174 174 | 
             
                refute test_user.valid?
         | 
| 175 | 
            -
                assert test_user.errors[:email].include?("is  | 
| 175 | 
            +
                assert test_user.errors[:email].include?("is improperly formatted")
         | 
| 176 176 | 
             
              end
         | 
| 177 177 |  | 
| 178 178 | 
             
              def test_custom_message_on_error
         | 
| 179 179 | 
             
                test_user = TestUserWithMessage.new(:email => "invalid_email@")
         | 
| 180 180 | 
             
                refute test_user.valid?
         | 
| 181 | 
            -
                assert test_user.errors[:email].include?("is not formatted | 
| 181 | 
            +
                assert test_user.errors[:email].include?("is not well formatted")
         | 
| 182 182 | 
             
              end
         | 
| 183 183 |  | 
| 184 184 | 
             
              def test_nil_email_when_allow_nil_option_is_not_set
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: email_format_validator
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2011-11- | 
| 12 | 
            +
            date: 2011-11-14 00:00:00.000000000Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: activemodel
         | 
| 16 | 
            -
              requirement: & | 
| 16 | 
            +
              requirement: &70357299095340 !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,7 +21,7 @@ dependencies: | |
| 21 21 | 
             
                    version: '0'
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements: * | 
| 24 | 
            +
              version_requirements: *70357299095340
         | 
| 25 25 | 
             
            description: A Rails 3 email format validator with RFC 822 compliant option
         | 
| 26 26 | 
             
            email:
         | 
| 27 27 | 
             
            - axel.vergult@gmail.com
         |