schemacop 3.0.26 → 3.0.28
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/VERSION +1 -1
- data/lib/schemacop.rb +5 -0
- data/schemacop.gemspec +16 -44
- data/test/unit/schemacop/v3/string_node_test.rb +88 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff2b18b4f3426f6a06e4a9183c3b20375c5d55496929bdf30a569c19ad1cc28c
|
4
|
+
data.tar.gz: edb96299b93d5e49b6d5a8125fa2c95a73d6158c2cae4d4428c3fe9066b41244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49b290cbf2a7fdfc4b938fbdad9d4bd54469867fa46be22dc1a2158c32fe68266d1cce136d824a263689b9fdd9797ddfd601c7fa9fafbd37bb9adf3634f126ba
|
7
|
+
data.tar.gz: 73241d7daed75ad77a230904821749dcb0e954f8c3c858bc207d9487dd4b7cffbe806ea7a64dffc28010e6dc27281133d5191129781ad2c462dbe2f395b76278
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 3.0.28 (2023-12-20)
|
4
|
+
|
5
|
+
* Fix `mailbox` format allowing incorrectly formatted strings
|
6
|
+
|
7
|
+
## 3.0.27 (2023-12-13)
|
8
|
+
|
9
|
+
* Add format `mailbox` to `str` node for Schemacop3 schemas
|
10
|
+
|
3
11
|
## 3.0.26 (2023-11-16)
|
4
12
|
|
5
13
|
* Lock dependency `ruby2_keywords` to the more open `>= 0.0.4`
|
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.28
|
data/lib/schemacop.rb
CHANGED
@@ -55,6 +55,11 @@ module Schemacop
|
|
55
55
|
handler: ->(value) { value }
|
56
56
|
)
|
57
57
|
|
58
|
+
register_string_formatter(
|
59
|
+
:mailbox,
|
60
|
+
pattern: /^("\p{Print}+"\s)?<#{URI::MailTo::EMAIL_REGEXP.source[2...-2]}>$/,
|
61
|
+
handler: ->(value) { value }
|
62
|
+
)
|
58
63
|
register_string_formatter(
|
59
64
|
:boolean,
|
60
65
|
pattern: /^(true|false|0|1)$/i,
|
data/schemacop.gemspec
CHANGED
@@ -1,60 +1,32 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: schemacop 3.0.
|
2
|
+
# stub: schemacop 3.0.28 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.28".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-20"
|
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
|
19
|
+
s.specification_version = 4
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
s.add_development_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
|
34
|
-
else
|
35
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 4.0"])
|
36
|
-
s.add_dependency(%q<ruby2_keywords>.freeze, [">= 0.0.4"])
|
37
|
-
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
38
|
-
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
39
|
-
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
40
|
-
s.add_dependency(%q<minitest-reporters>.freeze, [">= 0"])
|
41
|
-
s.add_dependency(%q<colorize>.freeze, [">= 0"])
|
42
|
-
s.add_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
|
43
|
-
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
44
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
45
|
-
s.add_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
|
46
|
-
end
|
47
|
-
else
|
48
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 4.0"])
|
49
|
-
s.add_dependency(%q<ruby2_keywords>.freeze, [">= 0.0.4"])
|
50
|
-
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
51
|
-
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
52
|
-
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
53
|
-
s.add_dependency(%q<minitest-reporters>.freeze, [">= 0"])
|
54
|
-
s.add_dependency(%q<colorize>.freeze, [">= 0"])
|
55
|
-
s.add_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
|
56
|
-
s.add_dependency(%q<pry>.freeze, [">= 0"])
|
57
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
58
|
-
s.add_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
|
59
|
-
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])
|
60
32
|
end
|
@@ -191,6 +191,94 @@ 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
|
+
# No angle brackets given
|
200
|
+
assert_validation 'john.doe@example.com' do
|
201
|
+
error '/', 'String does not match format "mailbox".'
|
202
|
+
end
|
203
|
+
|
204
|
+
# Only leading angle bracket given
|
205
|
+
assert_validation '<john.doe@example.com' do
|
206
|
+
error '/', 'String does not match format "mailbox".'
|
207
|
+
end
|
208
|
+
|
209
|
+
# Only trailing angle bracket given
|
210
|
+
assert_validation 'john.doe@example.com>' do
|
211
|
+
error '/', 'String does not match format "mailbox".'
|
212
|
+
end
|
213
|
+
|
214
|
+
# Both angle brackets given, OK
|
215
|
+
assert_validation '<john.doe@example.com>'
|
216
|
+
|
217
|
+
# Both angle brackets given but leading space, not okay
|
218
|
+
assert_validation ' <john.doe@example.com>' do
|
219
|
+
error '/', 'String does not match format "mailbox".'
|
220
|
+
end
|
221
|
+
|
222
|
+
# Invalid email address given
|
223
|
+
assert_validation ' <john>' do
|
224
|
+
error '/', 'String does not match format "mailbox".'
|
225
|
+
end
|
226
|
+
|
227
|
+
# Invalid email address given
|
228
|
+
assert_validation ' <john@>' do
|
229
|
+
error '/', 'String does not match format "mailbox".'
|
230
|
+
end
|
231
|
+
|
232
|
+
# Invalid email address given
|
233
|
+
assert_validation ' <@example.com>' do
|
234
|
+
error '/', 'String does not match format "mailbox".'
|
235
|
+
end
|
236
|
+
|
237
|
+
# Name given but no quotes
|
238
|
+
assert_validation 'John Doe <john.doe@example.com>' do
|
239
|
+
error '/', 'String does not match format "mailbox".'
|
240
|
+
end
|
241
|
+
|
242
|
+
# Name given but only leading quote
|
243
|
+
assert_validation '"John Doe <john.doe@example.com>' do
|
244
|
+
error '/', 'String does not match format "mailbox".'
|
245
|
+
end
|
246
|
+
|
247
|
+
# Name given but only trailing quote
|
248
|
+
assert_validation 'John Doe" <john.doe@example.com>' do
|
249
|
+
error '/', 'String does not match format "mailbox".'
|
250
|
+
end
|
251
|
+
|
252
|
+
# Name given but no space between mail and name
|
253
|
+
assert_validation '"John Doe"<john.doe@example.com>' do
|
254
|
+
error '/', 'String does not match format "mailbox".'
|
255
|
+
end
|
256
|
+
|
257
|
+
# Too many brackets at start
|
258
|
+
assert_validation '"John Doe" <<john.doe@example.com>' do
|
259
|
+
error '/', 'String does not match format "mailbox".'
|
260
|
+
end
|
261
|
+
|
262
|
+
# Too many brackets at end
|
263
|
+
assert_validation '"John Doe" <john.doe@example.com>>' do
|
264
|
+
error '/', 'String does not match format "mailbox".'
|
265
|
+
end
|
266
|
+
|
267
|
+
# Name with quotes and space before mail, OK
|
268
|
+
assert_validation '"John Doe" <john.doe@example.com>'
|
269
|
+
|
270
|
+
# Name with quotes and space before mail with special characters, OK
|
271
|
+
assert_validation '"Jöhn Doé-Test" <john.doe@example.com>'
|
272
|
+
|
273
|
+
# Name with quotes and space before mail with angle bracket in name, OK
|
274
|
+
assert_validation '"John < Doe" <john.doe@example.com>'
|
275
|
+
|
276
|
+
assert_cast(nil, nil)
|
277
|
+
assert_cast('<john.doe@example.com>', '<john.doe@example.com>')
|
278
|
+
assert_cast('"John Doe" <john.doe@example.com>', '"John Doe" <john.doe@example.com>')
|
279
|
+
assert_cast('"Jöhn Doé-Test" <john.doe@example.com>', '"Jöhn Doé-Test" <john.doe@example.com>')
|
280
|
+
end
|
281
|
+
|
194
282
|
def test_format_boolean
|
195
283
|
schema :string, format: :boolean
|
196
284
|
|
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.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -164,8 +164,8 @@ dependencies:
|
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 0.21.2
|
167
|
-
description:
|
168
|
-
email:
|
167
|
+
description:
|
168
|
+
email:
|
169
169
|
executables: []
|
170
170
|
extensions: []
|
171
171
|
extra_rdoc_files: []
|
@@ -277,7 +277,7 @@ homepage: https://github.com/sitrox/schemacop
|
|
277
277
|
licenses:
|
278
278
|
- MIT
|
279
279
|
metadata: {}
|
280
|
-
post_install_message:
|
280
|
+
post_install_message:
|
281
281
|
rdoc_options: []
|
282
282
|
require_paths:
|
283
283
|
- lib
|
@@ -292,8 +292,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
292
|
- !ruby/object:Gem::Version
|
293
293
|
version: '0'
|
294
294
|
requirements: []
|
295
|
-
rubygems_version: 3.4.
|
296
|
-
signing_key:
|
295
|
+
rubygems_version: 3.4.22
|
296
|
+
signing_key:
|
297
297
|
specification_version: 4
|
298
298
|
summary: Schemacop validates ruby structures consisting of nested hashes and arrays
|
299
299
|
against simple schema definitions.
|