validates_timeliness 7.0.0 → 8.0.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -20
- data/CHANGELOG.md +14 -0
- data/README.md +3 -2
- data/gemfiles/{rails_7_0.gemfile → rails_8_0.gemfile} +2 -2
- data/lib/validates_timeliness/validator.rb +14 -5
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/validates_timeliness/validator_spec.rb +20 -0
- data/validates_timeliness.gemspec +1 -1
- metadata +8 -10
- data/gemfiles/rails_7_1.gemfile +0 -13
- data/gemfiles/rails_7_2.gemfile +0 -13
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fddd24dc1daff9d9c90db6d6cb477519ab77abcf5dc8c55c5c69af61504eba46
         | 
| 4 | 
            +
              data.tar.gz: e16bbad97a83834a912610ff682fe2c93ef7204e0b19f070becd84e4e3ebaf18
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 443d66dd2feb66c01e77294236fbf7b197e358246dbd40b9014c5b888e23810219851d89dd320db9e0a256bc62a6402fdbcc326684941566dbdc331285faefce
         | 
| 7 | 
            +
              data.tar.gz: 0d1f13688d2a26ffaa940b409c9f6139cd780b21ffffb1ef02470718bd63d3d1e86bf2bcf4e411b15de4cb7badb215cdd7df8088f59ff63f044f924fcbdf570d
         | 
    
        data/.github/workflows/ci.yml
    CHANGED
    
    | @@ -7,27 +7,9 @@ jobs: | |
| 7 7 | 
             
                  fail-fast: false
         | 
| 8 8 | 
             
                  matrix:
         | 
| 9 9 | 
             
                    include:
         | 
| 10 | 
            -
                      - gemfile:  | 
| 11 | 
            -
                        ruby: 2.7
         | 
| 12 | 
            -
                      - gemfile: rails_7_0
         | 
| 13 | 
            -
                        ruby: 3.0
         | 
| 14 | 
            -
                      - gemfile: rails_7_0
         | 
| 15 | 
            -
                        ruby: 3.1
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                      - gemfile: rails_7_1
         | 
| 18 | 
            -
                        ruby: 2.7
         | 
| 19 | 
            -
                      - gemfile: rails_7_1
         | 
| 20 | 
            -
                        ruby: 3.0
         | 
| 21 | 
            -
                      - gemfile: rails_7_1
         | 
| 22 | 
            -
                        ruby: 3.1
         | 
| 23 | 
            -
                      - gemfile: rails_7_1
         | 
| 24 | 
            -
                        ruby: 3.2
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                      - gemfile: rails_7_2
         | 
| 27 | 
            -
                        ruby: 3.1
         | 
| 28 | 
            -
                      - gemfile: rails_7_2
         | 
| 10 | 
            +
                      - gemfile: rails_8_0
         | 
| 29 11 | 
             
                        ruby: 3.2
         | 
| 30 | 
            -
                      - gemfile:  | 
| 12 | 
            +
                      - gemfile: rails_8_0
         | 
| 31 13 | 
             
                        ruby: 3.3
         | 
| 32 14 |  | 
| 33 15 | 
             
                name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,17 @@ | |
| 1 | 
            +
            # 8.0.0 [2024-12-31]
         | 
| 2 | 
            +
            *   Support Rails v8.x
         | 
| 3 | 
            +
            *   Support passing non-reserved validation options to errors
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # 7.0.0 [2024-11-30]
         | 
| 6 | 
            +
            *   Support Rails v7.x
         | 
| 7 | 
            +
            *   Removed all method overrides in ActiveModel now that the datetime type correctly stores before_type_cast values.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # 6.0.1 [2023-01-12]
         | 
| 10 | 
            +
            *   TODO need to complete this
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # 6.0.0 [2022-10-20]
         | 
| 13 | 
            +
            *   TODO need to complete this
         | 
| 14 | 
            +
             | 
| 1 15 | 
             
            # 5.0.0 [2021-04-03]
         | 
| 2 16 | 
             
            *   Fix DateTimeSelect extension support (AquisTech)
         | 
| 3 17 | 
             
            *   Relaxed Timeliness dependency version which allows for >= 0.4.0 with
         | 
    
        data/README.md
    CHANGED
    
    | @@ -6,13 +6,14 @@ | |
| 6 6 |  | 
| 7 7 | 
             
            ## Description
         | 
| 8 8 |  | 
| 9 | 
            -
            Complete validation of dates, times and datetimes for Rails  | 
| 9 | 
            +
            Complete validation of dates, times and datetimes for Rails 8.x and ActiveModel.
         | 
| 10 10 |  | 
| 11 11 | 
             
            Older Rails versions:
         | 
| 12 12 |  | 
| 13 13 | 
             
            - Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
         | 
| 14 14 | 
             
            - Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
         | 
| 15 15 | 
             
            - Rails 6.x: [https://github.com/adzap/validates_timeliness/tree/6-0-stable]
         | 
| 16 | 
            +
            - Rails 7.x: [https://github.com/adzap/validates_timeliness/tree/7-0-stable]
         | 
| 16 17 |  | 
| 17 18 |  | 
| 18 19 | 
             
            ## Features
         | 
| @@ -30,7 +31,7 @@ Older Rails versions: | |
| 30 31 |  | 
| 31 32 | 
             
            In Gemfile
         | 
| 32 33 | 
             
            ```ruby
         | 
| 33 | 
            -
            gem 'validates_timeliness', '~>  | 
| 34 | 
            +
            gem 'validates_timeliness', '~> 8.0.0.beta1'
         | 
| 34 35 | 
             
            ```
         | 
| 35 36 |  | 
| 36 37 | 
             
            Run bundler:
         | 
| @@ -21,6 +21,8 @@ module ValidatesTimeliness | |
| 21 21 |  | 
| 22 22 | 
             
                RESTRICTION_ERROR_MESSAGE = "Error occurred validating %s for %s restriction:\n%s"
         | 
| 23 23 |  | 
| 24 | 
            +
                RESERVED_OPTIONS = (RESTRICTIONS.keys + RESTRICTIONS.keys.map { |option| :"#{option}_message" }).freeze
         | 
| 25 | 
            +
             | 
| 24 26 | 
             
                def self.kind
         | 
| 25 27 | 
             
                  :timeliness
         | 
| 26 28 | 
             
                end
         | 
| @@ -72,7 +74,7 @@ module ValidatesTimeliness | |
| 72 74 | 
             
                    begin
         | 
| 73 75 | 
             
                      restriction_value = @converter.type_cast_value(@converter.evaluate(options[restriction], record))
         | 
| 74 76 | 
             
                      unless value.send(RESTRICTIONS[restriction], restriction_value)
         | 
| 75 | 
            -
                        add_error(record, attr_name, restriction, restriction_value) and break
         | 
| 77 | 
            +
                        add_error(record, attr_name, restriction, value: value, restriction_value: restriction_value) and break
         | 
| 76 78 | 
             
                      end
         | 
| 77 79 | 
             
                    rescue => e
         | 
| 78 80 | 
             
                      unless ValidatesTimeliness.ignore_restriction_errors
         | 
| @@ -83,13 +85,20 @@ module ValidatesTimeliness | |
| 83 85 | 
             
                  end
         | 
| 84 86 | 
             
                end
         | 
| 85 87 |  | 
| 86 | 
            -
                def add_error(record, attr_name, message, value | 
| 87 | 
            -
                   | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 88 | 
            +
                def add_error(record, attr_name, message, restriction_value: nil, value: nil)
         | 
| 89 | 
            +
                  error_options = options.except(*RESERVED_OPTIONS).merge!(
         | 
| 90 | 
            +
                    restriction: format_error_value(restriction_value),
         | 
| 91 | 
            +
                    value: value
         | 
| 92 | 
            +
                  )
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  message_text = options[:"#{message}_message"]
         | 
| 95 | 
            +
                  error_options[:message] = message_text if message_text.present?
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                  record.errors.add(attr_name, message, **error_options)
         | 
| 90 98 | 
             
                end
         | 
| 91 99 |  | 
| 92 100 | 
             
                def format_error_value(value)
         | 
| 101 | 
            +
                  return unless value
         | 
| 93 102 | 
             
                  format = I18n.t(@type, default: DEFAULT_ERROR_VALUE_FORMATS[@type], scope: 'validates_timeliness.error_value_formats')
         | 
| 94 103 | 
             
                  value.strftime(format)
         | 
| 95 104 | 
             
                end
         | 
| @@ -185,6 +185,26 @@ RSpec.describe ValidatesTimeliness::Validator do | |
| 185 185 | 
             
                end
         | 
| 186 186 | 
             
              end
         | 
| 187 187 |  | 
| 188 | 
            +
              describe "custom option" do
         | 
| 189 | 
            +
                it "should pass custom options to the error" do
         | 
| 190 | 
            +
                  Person.validates_datetime :birth_datetime, :on_or_before => Time.utc(2010,1,2,3,4,5), :custom => 'option'
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                  with_each_model_value(:birth_datetime, Time.utc(2010,1,2,3,4,5,10000), Person) do |record, value|
         | 
| 193 | 
            +
                    expect(record).to_not be_valid
         | 
| 194 | 
            +
                    expect(record.errors.where(:birth_datetime).first.options).to include(custom: 'option')
         | 
| 195 | 
            +
                  end
         | 
| 196 | 
            +
                end
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                it "should not pass config options to the error" do
         | 
| 199 | 
            +
                  Person.validates_datetime :birth_datetime, :on_or_before => Time.utc(2010,1,2,3,4,5), :custom => 'option'
         | 
| 200 | 
            +
             | 
| 201 | 
            +
                  with_each_model_value(:birth_datetime, Time.utc(2010,1,2,3,4,5,10000), Person) do |record, value|
         | 
| 202 | 
            +
                    expect(record).to_not be_valid
         | 
| 203 | 
            +
                    expect(record.errors.where(:birth_datetime).first.options.keys).to_not include(:on_or_before)
         | 
| 204 | 
            +
                  end
         | 
| 205 | 
            +
                end
         | 
| 206 | 
            +
              end
         | 
| 207 | 
            +
             | 
| 188 208 | 
             
              describe "restriction value errors" do
         | 
| 189 209 | 
             
                let(:person) { Person.new(:birth_date => Date.today) }
         | 
| 190 210 |  | 
| @@ -28,6 +28,6 @@ Gem::Specification.new do |s| | |
| 28 28 | 
             
                "wiki_uri"        => "#{github_url}/wiki",
         | 
| 29 29 | 
             
              }
         | 
| 30 30 |  | 
| 31 | 
            -
              s.add_runtime_dependency("activemodel", [">=  | 
| 31 | 
            +
              s.add_runtime_dependency("activemodel", [">= 8.0.0", "< 9"])
         | 
| 32 32 | 
             
              s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
         | 
| 33 33 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: validates_timeliness
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 8.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Adam Meehan
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-12-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activemodel
         | 
| @@ -16,20 +16,20 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 8.0.0
         | 
| 20 20 | 
             
                - - "<"
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            -
                    version: ' | 
| 22 | 
            +
                    version: '9'
         | 
| 23 23 | 
             
              type: :runtime
         | 
| 24 24 | 
             
              prerelease: false
         | 
| 25 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - ">="
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version:  | 
| 29 | 
            +
                    version: 8.0.0
         | 
| 30 30 | 
             
                - - "<"
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            -
                    version: ' | 
| 32 | 
            +
                    version: '9'
         | 
| 33 33 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 34 34 | 
             
              name: timeliness
         | 
| 35 35 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -66,9 +66,7 @@ files: | |
| 66 66 | 
             
            - LICENSE
         | 
| 67 67 | 
             
            - README.md
         | 
| 68 68 | 
             
            - Rakefile
         | 
| 69 | 
            -
            - gemfiles/ | 
| 70 | 
            -
            - gemfiles/rails_7_1.gemfile
         | 
| 71 | 
            -
            - gemfiles/rails_7_2.gemfile
         | 
| 69 | 
            +
            - gemfiles/rails_8_0.gemfile
         | 
| 72 70 | 
             
            - init.rb
         | 
| 73 71 | 
             
            - lib/generators/validates_timeliness/install_generator.rb
         | 
| 74 72 | 
             
            - lib/generators/validates_timeliness/templates/en.yml
         | 
| @@ -131,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 131 129 | 
             
                - !ruby/object:Gem::Version
         | 
| 132 130 | 
             
                  version: '0'
         | 
| 133 131 | 
             
            requirements: []
         | 
| 134 | 
            -
            rubygems_version: 3. | 
| 132 | 
            +
            rubygems_version: 3.4.19
         | 
| 135 133 | 
             
            signing_key:
         | 
| 136 134 | 
             
            specification_version: 4
         | 
| 137 135 | 
             
            summary: Date and time validation plugin for Rails which allows custom formats
         | 
    
        data/gemfiles/rails_7_1.gemfile
    DELETED
    
    
    
        data/gemfiles/rails_7_2.gemfile
    DELETED