schemacop 3.0.20 → 3.0.21
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/CHANGELOG.md +5 -0
- data/README_V3.md +3 -0
- data/VERSION +1 -1
- data/lib/schemacop/v3/hash_node.rb +3 -1
- data/schemacop.gemspec +3 -3
- data/test/unit/schemacop/v3/hash_node_test.rb +37 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5e052fc48d690551076d72ec99fe2b3189e7e92861c70ea1b13d6ce2ab7e0f86
         | 
| 4 | 
            +
              data.tar.gz: e6bf934bc3c8489639b6f492a71d699f397b3ffcc67d573b18e19656b46648b5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1e916b157d4f36beebfc698f8680a3d8cc5283b49b7e95c56fe6c270851ae9c43fc3769bae7ea9829aca2d121774b8c809c1c9b271bd5ad901587498f9a43695
         | 
| 7 | 
            +
              data.tar.gz: 6faa79d40c4dcc045c33072f06327599fd98e853f1d3e416c4163df47326cc2ee13555b4fe6c2100b90e0604dc1e30e5d32ae3ca02515b4ce5545dc8bcd73bba
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,10 @@ | |
| 1 1 | 
             
            # Change log
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 3.0.21 (2022-10-31)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * Adapt option `ignore_obsolete_properties` of `HashNode` so that it can also
         | 
| 6 | 
            +
              function as a parameter white-list when set to an enumerable.
         | 
| 7 | 
            +
             | 
| 3 8 | 
             
            ## 3.0.20 (2022-09-29)
         | 
| 4 9 |  | 
| 5 10 | 
             
            * Improve error messages for `all_of`, `any_of` and `one_of`
         | 
    
        data/README_V3.md
    CHANGED
    
    | @@ -873,6 +873,9 @@ It consists of key-value-pairs that can be validated using arbitrary nodes. | |
| 873 873 | 
             
              controller, as this only allows white-listed params and removes any params
         | 
| 874 874 | 
             
              which are not whitelisted (i.e. similar to strong params from Rails).
         | 
| 875 875 |  | 
| 876 | 
            +
              If it is set to an enumerable (e.g. `Set` or `Array`), it functions as a
         | 
| 877 | 
            +
              white-list and only the given additional properties are allowed.
         | 
| 878 | 
            +
             | 
| 876 879 | 
             
            #### Specifying properties
         | 
| 877 880 |  | 
| 878 881 | 
             
            Hash nodes support a block in which you can specify the required hash contents.
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            3.0. | 
| 1 | 
            +
            3.0.21
         | 
| @@ -141,7 +141,9 @@ module Schemacop | |
| 141 141 | 
             
                          result.in_path(name) do
         | 
| 142 142 | 
             
                            property_patterns[match]._validate(additional_property, result: result)
         | 
| 143 143 | 
             
                          end
         | 
| 144 | 
            -
                        elsif  | 
| 144 | 
            +
                        elsif (options[:ignore_obsolete_properties].is_a?(Enumerable) &&
         | 
| 145 | 
            +
                               options[:ignore_obsolete_properties].exclude?(name.to_sym)) ||
         | 
| 146 | 
            +
                              !options[:ignore_obsolete_properties]
         | 
| 145 147 | 
             
                          result.error "Obsolete property #{name.to_s.inspect}."
         | 
| 146 148 | 
             
                        end
         | 
| 147 149 | 
             
                      elsif options[:additional_properties].is_a?(Node)
         | 
    
        data/schemacop.gemspec
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            -
            # stub: schemacop 3.0. | 
| 2 | 
            +
            # stub: schemacop 3.0.21 ruby lib
         | 
| 3 3 |  | 
| 4 4 | 
             
            Gem::Specification.new do |s|
         | 
| 5 5 | 
             
              s.name = "schemacop".freeze
         | 
| 6 | 
            -
              s.version = "3.0. | 
| 6 | 
            +
              s.version = "3.0.21"
         | 
| 7 7 |  | 
| 8 8 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
         | 
| 9 9 | 
             
              s.require_paths = ["lib".freeze]
         | 
| 10 10 | 
             
              s.authors = ["Sitrox".freeze]
         | 
| 11 | 
            -
              s.date = "2022- | 
| 11 | 
            +
              s.date = "2022-10-31"
         | 
| 12 12 | 
             
              s.files = [".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "README_V2.md".freeze, "README_V3.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "lib/schemacop.rb".freeze, "lib/schemacop/base_schema.rb".freeze, "lib/schemacop/exceptions.rb".freeze, "lib/schemacop/railtie.rb".freeze, "lib/schemacop/schema.rb".freeze, "lib/schemacop/schema2.rb".freeze, "lib/schemacop/schema3.rb".freeze, "lib/schemacop/scoped_env.rb".freeze, "lib/schemacop/v2.rb".freeze, "lib/schemacop/v2/caster.rb".freeze, "lib/schemacop/v2/collector.rb".freeze, "lib/schemacop/v2/dupper.rb".freeze, "lib/schemacop/v2/field_node.rb".freeze, "lib/schemacop/v2/node.rb".freeze, "lib/schemacop/v2/node_resolver.rb".freeze, "lib/schemacop/v2/node_supporting_field.rb".freeze, "lib/schemacop/v2/node_supporting_type.rb".freeze, "lib/schemacop/v2/node_with_block.rb".freeze, "lib/schemacop/v2/validator/array_validator.rb".freeze, "lib/schemacop/v2/validator/boolean_validator.rb".freeze, "lib/schemacop/v2/validator/float_validator.rb".freeze, "lib/schemacop/v2/validator/hash_validator.rb".freeze, "lib/schemacop/v2/validator/integer_validator.rb".freeze, "lib/schemacop/v2/validator/nil_validator.rb".freeze, "lib/schemacop/v2/validator/number_validator.rb".freeze, "lib/schemacop/v2/validator/object_validator.rb".freeze, "lib/schemacop/v2/validator/string_validator.rb".freeze, "lib/schemacop/v2/validator/symbol_validator.rb".freeze, "lib/schemacop/v3.rb".freeze, "lib/schemacop/v3/all_of_node.rb".freeze, "lib/schemacop/v3/any_of_node.rb".freeze, "lib/schemacop/v3/array_node.rb".freeze, "lib/schemacop/v3/boolean_node.rb".freeze, "lib/schemacop/v3/combination_node.rb".freeze, "lib/schemacop/v3/context.rb".freeze, "lib/schemacop/v3/dsl_scope.rb".freeze, "lib/schemacop/v3/global_context.rb".freeze, "lib/schemacop/v3/hash_node.rb".freeze, "lib/schemacop/v3/integer_node.rb".freeze, "lib/schemacop/v3/is_not_node.rb".freeze, "lib/schemacop/v3/node.rb".freeze, "lib/schemacop/v3/node_registry.rb".freeze, "lib/schemacop/v3/number_node.rb".freeze, "lib/schemacop/v3/numeric_node.rb".freeze, "lib/schemacop/v3/object_node.rb".freeze, "lib/schemacop/v3/one_of_node.rb".freeze, "lib/schemacop/v3/reference_node.rb".freeze, "lib/schemacop/v3/result.rb".freeze, "lib/schemacop/v3/string_node.rb".freeze, "lib/schemacop/v3/symbol_node.rb".freeze, "schemacop.gemspec".freeze, "test/lib/test_helper.rb".freeze, "test/schemas/nested/group.rb".freeze, "test/schemas/user.rb".freeze, "test/unit/schemacop/v2/casting_test.rb".freeze, "test/unit/schemacop/v2/collector_test.rb".freeze, "test/unit/schemacop/v2/custom_check_test.rb".freeze, "test/unit/schemacop/v2/custom_if_test.rb".freeze, "test/unit/schemacop/v2/defaults_test.rb".freeze, "test/unit/schemacop/v2/empty_test.rb".freeze, "test/unit/schemacop/v2/nil_dis_allow_test.rb".freeze, "test/unit/schemacop/v2/node_resolver_test.rb".freeze, "test/unit/schemacop/v2/short_forms_test.rb".freeze, "test/unit/schemacop/v2/types_test.rb".freeze, "test/unit/schemacop/v2/validator_array_test.rb".freeze, "test/unit/schemacop/v2/validator_boolean_test.rb".freeze, "test/unit/schemacop/v2/validator_float_test.rb".freeze, "test/unit/schemacop/v2/validator_hash_test.rb".freeze, "test/unit/schemacop/v2/validator_integer_test.rb".freeze, "test/unit/schemacop/v2/validator_nil_test.rb".freeze, "test/unit/schemacop/v2/validator_number_test.rb".freeze, "test/unit/schemacop/v2/validator_object_test.rb".freeze, "test/unit/schemacop/v2/validator_string_test.rb".freeze, "test/unit/schemacop/v2/validator_symbol_test.rb".freeze, "test/unit/schemacop/v3/all_of_node_test.rb".freeze, "test/unit/schemacop/v3/any_of_node_test.rb".freeze, "test/unit/schemacop/v3/array_node_test.rb".freeze, "test/unit/schemacop/v3/boolean_node_test.rb".freeze, "test/unit/schemacop/v3/global_context_test.rb".freeze, "test/unit/schemacop/v3/hash_node_test.rb".freeze, "test/unit/schemacop/v3/integer_node_test.rb".freeze, "test/unit/schemacop/v3/is_not_node_test.rb".freeze, "test/unit/schemacop/v3/node_test.rb".freeze, "test/unit/schemacop/v3/number_node_test.rb".freeze, "test/unit/schemacop/v3/object_node_test.rb".freeze, "test/unit/schemacop/v3/one_of_node_test.rb".freeze, "test/unit/schemacop/v3/reference_node_test.rb".freeze, "test/unit/schemacop/v3/string_node_test.rb".freeze, "test/unit/schemacop/v3/symbol_node_test.rb".freeze]
         | 
| 13 13 | 
             
              s.homepage = "https://github.com/sitrox/schemacop".freeze
         | 
| 14 14 | 
             
              s.licenses = ["MIT".freeze]
         | 
| @@ -1074,6 +1074,43 @@ module Schemacop | |
| 1074 1074 | 
             
                    assert_cast({ foo: 1, bar: 'baz', obsolete_key: 42 }, { foo: 1, bar: 'baz' }.with_indifferent_access)
         | 
| 1075 1075 | 
             
                  end
         | 
| 1076 1076 |  | 
| 1077 | 
            +
                  def test_ignore_obsolete_properties_whitelist
         | 
| 1078 | 
            +
                    schema :hash, ignore_obsolete_properties: %i[obsolete_key] do
         | 
| 1079 | 
            +
                      int? :foo
         | 
| 1080 | 
            +
                      str? :bar
         | 
| 1081 | 
            +
                    end
         | 
| 1082 | 
            +
             | 
| 1083 | 
            +
                    # Some standard validations first
         | 
| 1084 | 
            +
                    assert_validation({})
         | 
| 1085 | 
            +
                    assert_validation({ foo: 1 })
         | 
| 1086 | 
            +
                    assert_validation({ bar: 'baz' })
         | 
| 1087 | 
            +
                    assert_validation({ foo: 1, bar: 'baz' })
         | 
| 1088 | 
            +
                    assert_validation({ foo: 1, bar: 'baz', baz: 'foo' }) do
         | 
| 1089 | 
            +
                      error '/', 'Obsolete property "baz".'
         | 
| 1090 | 
            +
                    end
         | 
| 1091 | 
            +
             | 
| 1092 | 
            +
                    assert_cast({}, {}.with_indifferent_access)
         | 
| 1093 | 
            +
                    assert_cast({ foo: 1 }, { foo: 1 }.with_indifferent_access)
         | 
| 1094 | 
            +
                    assert_cast({ bar: 'baz' }, { bar: 'baz' }.with_indifferent_access)
         | 
| 1095 | 
            +
                    assert_cast({ foo: 1, bar: 'baz' }, { foo: 1, bar: 'baz' }.with_indifferent_access)
         | 
| 1096 | 
            +
             | 
| 1097 | 
            +
                    # Should allow obsolete properties and remove them from the result
         | 
| 1098 | 
            +
                    assert_validation({ obsolete_key: 42 })
         | 
| 1099 | 
            +
                    assert_validation({ foo: 1, obsolete_key: 42 })
         | 
| 1100 | 
            +
                    assert_validation({ bar: 'baz', obsolete_key: 42 })
         | 
| 1101 | 
            +
                    assert_validation({ foo: 1, bar: 'baz', obsolete_key: 42 })
         | 
| 1102 | 
            +
             | 
| 1103 | 
            +
                    assert_cast({ obsolete_key: 42 }, {}.with_indifferent_access)
         | 
| 1104 | 
            +
                    assert_cast({ foo: 1, obsolete_key: 42 }, { foo: 1 }.with_indifferent_access)
         | 
| 1105 | 
            +
                    assert_cast({ bar: 'baz', obsolete_key: 42 }, { bar: 'baz' }.with_indifferent_access)
         | 
| 1106 | 
            +
                    assert_cast({ foo: 1, bar: 'baz', obsolete_key: 42 }, { foo: 1, bar: 'baz' }.with_indifferent_access)
         | 
| 1107 | 
            +
             | 
| 1108 | 
            +
                    assert_cast({ obsolete_key: 42 }, {}.with_indifferent_access)
         | 
| 1109 | 
            +
                    assert_cast({ foo: 1, obsolete_key: 42 }, { foo: 1 }.with_indifferent_access)
         | 
| 1110 | 
            +
                    assert_cast({ bar: 'baz', obsolete_key: 42 }, { bar: 'baz' }.with_indifferent_access)
         | 
| 1111 | 
            +
                    assert_cast({ foo: 1, bar: 'baz', obsolete_key: 42 }, { foo: 1, bar: 'baz' }.with_indifferent_access)
         | 
| 1112 | 
            +
                  end
         | 
| 1113 | 
            +
             | 
| 1077 1114 | 
             
                  def test_ignore_obsolete_properties_false
         | 
| 1078 1115 | 
             
                    schema :hash, ignore_obsolete_properties: false do
         | 
| 1079 1116 | 
             
                      int? :foo
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: schemacop
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.0. | 
| 4 | 
            +
              version: 3.0.21
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sitrox
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-10-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |