schemacop 3.0.25 → 3.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README_V3.md +5 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/schemacop.rb +6 -0
- data/schemacop.gemspec +16 -32
- data/test/unit/schemacop/v3/string_node_test.rb +44 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c0fc96299ed96cd4716792ebff5cd534a382bf0b3b986cf857a36041cba6da3
|
4
|
+
data.tar.gz: 2d3c689728bc7e9ebc5138be0b2b2cb9a06d2e77557914cc18880507c3d59cfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b9d0c4299ab4a94b70ecddcaf90ffee54b810f2b02f311afdd9d63dd7491f27382813211c2d4d66ceffbf2ab761f8b37b5a878daea227211c9bdfbf12214054
|
7
|
+
data.tar.gz: 381b90a930cc66ff5e098db51daf97aef4b30906ab4d0d9824d2616453e3144eb3adb42c84604a11608d1f83564722fff72d53d64eb1b9b433cc95d9773eadb9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 3.0.27 (2023-12-13)
|
4
|
+
|
5
|
+
* Add format `mailbox` to `str` node for Schemacop3 schemas
|
6
|
+
|
7
|
+
## 3.0.26 (2023-11-16)
|
8
|
+
|
9
|
+
* Lock dependency `ruby2_keywords` to the more open `>= 0.0.4`
|
10
|
+
|
3
11
|
## 3.0.25 (2023-10-30)
|
4
12
|
|
5
13
|
* Improve documentation: list validation
|
data/README_V3.md
CHANGED
@@ -243,6 +243,11 @@ transformed into various types.
|
|
243
243
|
Validates for a valid email address. There is no casting involved since email
|
244
244
|
addresses do not have their own ruby type.
|
245
245
|
|
246
|
+
* `mailbox`
|
247
|
+
Validates for a valid mailbox, which is defined as a valid email enclosed in
|
248
|
+
brackets (`< >`), with an optional name before the email address. There is no
|
249
|
+
casting involved.
|
250
|
+
|
246
251
|
* `boolean`
|
247
252
|
The string must be either `true`, `false`, `0` or `1`. This value will be
|
248
253
|
casted to Ruby's `TrueClass` or `FalseClass`. Please note that the strings
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ task :gemspec do
|
|
18
18
|
# needs access to ActiveSupport::HashWithIndifferentAccess and expects
|
19
19
|
# behavior of that as in version 5 of ActiveSupport.
|
20
20
|
spec.add_dependency 'activesupport', '>= 4.0'
|
21
|
-
spec.add_dependency 'ruby2_keywords', '0.0.4'
|
21
|
+
spec.add_dependency 'ruby2_keywords', '>= 0.0.4'
|
22
22
|
spec.add_development_dependency 'bundler'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
24
|
spec.add_development_dependency 'minitest'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.27
|
data/lib/schemacop.rb
CHANGED
@@ -55,6 +55,12 @@ module Schemacop
|
|
55
55
|
handler: ->(value) { value }
|
56
56
|
)
|
57
57
|
|
58
|
+
register_string_formatter(
|
59
|
+
:mailbox,
|
60
|
+
pattern: %r{^.*\s?<[a-zA-Z0-9.!\#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>$},
|
61
|
+
handler: ->(value) { value }
|
62
|
+
)
|
63
|
+
|
58
64
|
register_string_formatter(
|
59
65
|
:boolean,
|
60
66
|
pattern: /^(true|false|0|1)$/i,
|
data/schemacop.gemspec
CHANGED
@@ -1,48 +1,32 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: schemacop 3.0.
|
2
|
+
# stub: schemacop 3.0.27 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.27".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 = "2023-
|
11
|
+
s.date = "2023-12-13"
|
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.4.22".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
|
-
|
20
|
-
s.specification_version = 4
|
21
|
-
end
|
19
|
+
s.specification_version = 4
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
s.add_development_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
|
35
|
-
else
|
36
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 4.0"])
|
37
|
-
s.add_dependency(%q<ruby2_keywords>.freeze, ["= 0.0.4"])
|
38
|
-
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
39
|
-
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
40
|
-
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
41
|
-
s.add_dependency(%q<minitest-reporters>.freeze, [">= 0"])
|
42
|
-
s.add_dependency(%q<colorize>.freeze, [">= 0"])
|
43
|
-
s.add_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
|
44
|
-
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
45
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
46
|
-
s.add_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
|
47
|
-
end
|
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
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0".freeze])
|
24
|
+
s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
|
25
|
+
s.add_development_dependency(%q<minitest>.freeze, [">= 0".freeze])
|
26
|
+
s.add_development_dependency(%q<minitest-reporters>.freeze, [">= 0".freeze])
|
27
|
+
s.add_development_dependency(%q<colorize>.freeze, [">= 0".freeze])
|
28
|
+
s.add_development_dependency(%q<rubocop>.freeze, ["= 1.24.1".freeze])
|
29
|
+
s.add_development_dependency(%q<pry>.freeze, [">= 0".freeze])
|
30
|
+
s.add_development_dependency(%q<byebug>.freeze, [">= 0".freeze])
|
31
|
+
s.add_development_dependency(%q<simplecov>.freeze, ["= 0.21.2".freeze])
|
48
32
|
end
|
@@ -191,6 +191,50 @@ module Schemacop
|
|
191
191
|
assert_cast('john.doe@example.com', 'john.doe@example.com')
|
192
192
|
end
|
193
193
|
|
194
|
+
def test_format_mailbox
|
195
|
+
schema :string, format: :mailbox
|
196
|
+
|
197
|
+
assert_json(type: :string, format: :mailbox)
|
198
|
+
|
199
|
+
assert_validation 'john.doe@example.com' do
|
200
|
+
error '/', 'String does not match format "mailbox".'
|
201
|
+
end
|
202
|
+
|
203
|
+
assert_validation 'john.doe+foo-bar_baz@example.com' do
|
204
|
+
error '/', 'String does not match format "mailbox".'
|
205
|
+
end
|
206
|
+
|
207
|
+
assert_validation 'JOHN.DOE+FOO-BAR_BAZ@EXAMPLE.COM' do
|
208
|
+
error '/', 'String does not match format "mailbox".'
|
209
|
+
end
|
210
|
+
|
211
|
+
assert_validation 'someemail' do
|
212
|
+
error '/', 'String does not match format "mailbox".'
|
213
|
+
end
|
214
|
+
|
215
|
+
assert_validation 'john doe@example.com' do
|
216
|
+
error '/', 'String does not match format "mailbox".'
|
217
|
+
end
|
218
|
+
|
219
|
+
assert_validation '@john@example.com' do
|
220
|
+
error '/', 'String does not match format "mailbox".'
|
221
|
+
end
|
222
|
+
|
223
|
+
assert_validation 'John Doe <john.doe@example.com>'
|
224
|
+
assert_validation 'John Doe <john.doe+foo-bar_baz@example.com>'
|
225
|
+
assert_validation 'John Doe <JOHN.DOE+FOO-BAR_BAZ@EXAMPLE.COM>'
|
226
|
+
|
227
|
+
assert_validation 'John <john.doe@example.com>'
|
228
|
+
assert_validation 'John Doe 123 <john.doe@example.com>'
|
229
|
+
assert_validation 'John_Doe <john.doe@example.com>'
|
230
|
+
assert_validation 'John-Doe ÖÄ <john.doe@example.com>'
|
231
|
+
assert_validation '"John Doe" <john.doe@example.com>'
|
232
|
+
assert_validation '<john.doe@example.com>'
|
233
|
+
|
234
|
+
assert_cast(nil, nil)
|
235
|
+
assert_cast('John Doe <john.doe@example.com>', 'John Doe <john.doe@example.com>')
|
236
|
+
end
|
237
|
+
|
194
238
|
def test_format_boolean
|
195
239
|
schema :string, format: :boolean
|
196
240
|
|
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.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: ruby2_keywords
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.0.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.0.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -292,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
292
|
- !ruby/object:Gem::Version
|
293
293
|
version: '0'
|
294
294
|
requirements: []
|
295
|
-
rubygems_version: 3.
|
295
|
+
rubygems_version: 3.4.22
|
296
296
|
signing_key:
|
297
297
|
specification_version: 4
|
298
298
|
summary: Schemacop validates ruby structures consisting of nested hashes and arrays
|