schemacop 3.0.26 → 3.0.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23f9d2f61955b57515d279b5ca4306aada1636d0935b6dad4c6cbe9a1e08a7ac
4
- data.tar.gz: f618057644a8584dbf375a6544915eccc266226ad1e483c30035d992f26c06a5
3
+ metadata.gz: 3c0fc96299ed96cd4716792ebff5cd534a382bf0b3b986cf857a36041cba6da3
4
+ data.tar.gz: 2d3c689728bc7e9ebc5138be0b2b2cb9a06d2e77557914cc18880507c3d59cfb
5
5
  SHA512:
6
- metadata.gz: a52ea42b484fca411e9f75db534f30f948334f683d6982b124a3ec324075c5f78efd03c75be0b372f0b0702b80c137a6c73de9418a17f8bb57ac05c073df77ce
7
- data.tar.gz: a731ef060906674ac381311b64b021f7315601ff46d4884828bdd5a4cf39e8e580144f28d637675a5ef0ca26acd04e711b813cbca5082ff3d365e9ba04a37332
6
+ metadata.gz: 1b9d0c4299ab4a94b70ecddcaf90ffee54b810f2b02f311afdd9d63dd7491f27382813211c2d4d66ceffbf2ab761f8b37b5a878daea227211c9bdfbf12214054
7
+ data.tar.gz: 381b90a930cc66ff5e098db51daf97aef4b30906ab4d0d9824d2616453e3144eb3adb42c84604a11608d1f83564722fff72d53d64eb1b9b433cc95d9773eadb9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  ## 3.0.26 (2023-11-16)
4
8
 
5
9
  * 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.26
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,60 +1,32 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: schemacop 3.0.26 ruby lib
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.26"
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-16"
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.0.3".freeze
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
- if s.respond_to? :specification_version then
20
- s.specification_version = 4
19
+ s.specification_version = 4
21
20
 
22
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
- s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4.0"])
24
- s.add_runtime_dependency(%q<ruby2_keywords>.freeze, [">= 0.0.4"])
25
- s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
26
- s.add_development_dependency(%q<rake>.freeze, [">= 0"])
27
- s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
28
- s.add_development_dependency(%q<minitest-reporters>.freeze, [">= 0"])
29
- s.add_development_dependency(%q<colorize>.freeze, [">= 0"])
30
- s.add_development_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
31
- s.add_development_dependency(%q<pry>.freeze, [">= 0"])
32
- s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
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,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.26
4
+ version: 3.0.27
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-16 00:00:00.000000000 Z
11
+ date: 2023-12-13 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.6
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.