schemacop 3.0.33 → 3.0.34
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 +7 -0
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/schemacop.rb +7 -1
- data/schemacop.gemspec +6 -6
- data/test/lib/test_helper.rb +5 -1
- data/test/unit/schemacop/v3/number_node_test.rb +8 -8
- metadata +3 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818a611a08d135cb5fb9c691a101472133c2313e5536675b62af795b01a56fbb
|
4
|
+
data.tar.gz: bea474ef2808294b83597bab07b076103b5ddddbe0d4aa2164bbed779f2cc130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f815986a0a382961c35445d710217a7af8bf9937fe6e137852e4c54c95bc9550b6796aa610f29e2b06aacd277e99eb2e19039bde2d8e1b6c0c5d27578db6b2a0
|
7
|
+
data.tar.gz: 0db3deb0605ae6a1315e91a58ca1beebfd74aabe7be9488df320736d1077c54ba993c4705b4a8f4b63c8adda3daf57c5a3e6b46639127daf9435a8e1b45544a1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 3.0.34 (2025-05-27)
|
4
|
+
|
5
|
+
* Adapt string format `number` to cast to `Integer` instead of to a `Float` if
|
6
|
+
the string does not contain a floating point number
|
7
|
+
|
8
|
+
Internal reference: `#137987`.
|
9
|
+
|
3
10
|
## 3.0.33 (2025-02-11)
|
4
11
|
|
5
12
|
* Fix bug marking subnet `/30` as invalid when using `ipv4-cidr` string format
|
data/RUBY_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.3.5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.34
|
data/lib/schemacop.rb
CHANGED
@@ -89,7 +89,13 @@ module Schemacop
|
|
89
89
|
register_string_formatter(
|
90
90
|
:number,
|
91
91
|
pattern: /^-?[0-9]+(\.[0-9]+)?$/,
|
92
|
-
handler:
|
92
|
+
handler: proc do |value|
|
93
|
+
if value.include?('.')
|
94
|
+
Float(value)
|
95
|
+
else
|
96
|
+
Integer(value, 10)
|
97
|
+
end
|
98
|
+
end
|
93
99
|
)
|
94
100
|
|
95
101
|
register_string_formatter(
|
data/schemacop.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: schemacop 3.0.
|
2
|
+
# stub: schemacop 3.0.34 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.34".freeze
|
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 = "2025-
|
11
|
+
s.date = "2025-05-27"
|
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]
|
15
|
-
s.rubygems_version = "3.
|
15
|
+
s.rubygems_version = "3.5.18".freeze
|
16
16
|
s.summary = "Schemacop validates ruby structures consisting of nested hashes and arrays against simple schema definitions.".freeze
|
17
17
|
s.test_files = ["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]
|
18
18
|
|
19
19
|
s.specification_version = 4
|
20
20
|
|
21
|
-
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4.0"])
|
22
|
-
s.add_runtime_dependency(%q<ruby2_keywords>.freeze, [">= 0.0.4"])
|
21
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4.0".freeze])
|
22
|
+
s.add_runtime_dependency(%q<ruby2_keywords>.freeze, [">= 0.0.4".freeze])
|
23
23
|
end
|
data/test/lib/test_helper.rb
CHANGED
@@ -166,7 +166,7 @@ class V3Test < SchemacopTest
|
|
166
166
|
"Expected any of #{array.inspect} to match #{exp}."
|
167
167
|
end
|
168
168
|
|
169
|
-
def assert_cast(input_data, expected_data)
|
169
|
+
def assert_cast(input_data, expected_data, check_type: false)
|
170
170
|
input_data_was = Marshal.load(Marshal.dump(input_data))
|
171
171
|
result = @schema.validate(input_data)
|
172
172
|
assert_empty result.errors
|
@@ -182,5 +182,9 @@ class V3Test < SchemacopTest
|
|
182
182
|
else
|
183
183
|
assert_equal input_data, input_data_was, 'Expected input_data to stay the same.'
|
184
184
|
end
|
185
|
+
|
186
|
+
if check_type
|
187
|
+
assert_equal expected_data.class, result.data.class, 'Unexpected casted type.'
|
188
|
+
end
|
185
189
|
end
|
186
190
|
end
|
@@ -313,19 +313,19 @@ module Schemacop
|
|
313
313
|
def test_cast_str
|
314
314
|
schema :number, cast_str: true, minimum: 0.0, maximum: 50r, multiple_of: BigDecimal('0.5')
|
315
315
|
|
316
|
-
assert_cast('1', 1)
|
317
|
-
assert_cast(1, 1)
|
316
|
+
assert_cast('1', 1, check_type: true)
|
317
|
+
assert_cast(1, 1, check_type: true)
|
318
318
|
|
319
|
-
assert_cast('08', 8)
|
320
|
-
assert_cast('09', 9)
|
321
|
-
assert_cast('050', 50)
|
322
|
-
assert_cast('01', 1)
|
319
|
+
assert_cast('08', 8, check_type: true)
|
320
|
+
assert_cast('09', 9, check_type: true)
|
321
|
+
assert_cast('050', 50, check_type: true)
|
322
|
+
assert_cast('01', 1, check_type: true)
|
323
323
|
|
324
324
|
assert_validation(nil)
|
325
325
|
assert_validation('')
|
326
326
|
|
327
|
-
assert_cast('1.0', 1.0)
|
328
|
-
assert_cast(1.0, 1.0)
|
327
|
+
assert_cast('1.0', 1.0, check_type: true)
|
328
|
+
assert_cast(1.0, 1.0, check_type: true)
|
329
329
|
|
330
330
|
assert_validation('42')
|
331
331
|
assert_validation('0.5')
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
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.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-05-27 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -38,8 +37,6 @@ dependencies:
|
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: 0.0.4
|
41
|
-
description:
|
42
|
-
email:
|
43
40
|
executables: []
|
44
41
|
extensions: []
|
45
42
|
extra_rdoc_files: []
|
@@ -151,7 +148,6 @@ homepage: https://github.com/sitrox/schemacop
|
|
151
148
|
licenses:
|
152
149
|
- MIT
|
153
150
|
metadata: {}
|
154
|
-
post_install_message:
|
155
151
|
rdoc_options: []
|
156
152
|
require_paths:
|
157
153
|
- lib
|
@@ -166,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
162
|
- !ruby/object:Gem::Version
|
167
163
|
version: '0'
|
168
164
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
170
|
-
signing_key:
|
165
|
+
rubygems_version: 3.6.8
|
171
166
|
specification_version: 4
|
172
167
|
summary: Schemacop validates ruby structures consisting of nested hashes and arrays
|
173
168
|
against simple schema definitions.
|