openapi_parser 0.5.0 → 0.6.0

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: 69b353b6b05a25b119a50ef0baf9fe56d749158a18e429e2ed3632effb0c2de7
4
- data.tar.gz: e122e4b7942ed9cb53fa70f0a7c9eef316fb6384342a5ff8b66cf9f998f9d95a
3
+ metadata.gz: d37b73f1501e0230ab8b3bf5f8a7482809d0d1bcbc5e52ae6975442993496ffb
4
+ data.tar.gz: 709cb3b9f0f65ea74abe91ff6639d8feb11f33b0c9fd2839589064b000cdc6ff
5
5
  SHA512:
6
- metadata.gz: f0ec9b54da1a51781be3786c6def47e4e673fda8fdf5ad6362813725362c7a0ce9a1464dcee37f9f629f4dab796fa623b8578c7182af9e3e0f28e6257318e03a
7
- data.tar.gz: 13effd1bac35ae340f98bd3127569f7bce3184586dc44a109016fc243e867731d6824973f0cc4607cf1095e2e05729f499b5528d108a109b192c7f48c5f9a823
6
+ metadata.gz: ea0e14b6b8110a0afe331bc77608d3ec7b530a8d6539d4433ed17ecf77eefaf7e0af9c56df1368a17ba65d4db75b085a57a1d5ddbb6e758202413a225c3faaac
7
+ data.tar.gz: 44559dc45ab5ecaa6630d4eb848b3746a8cbce90c31d313ad9a652b188e83584aa3773b89248865510de559a9dda0f0d38575e65fae5be18195a0aec0aca80eb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.6.0 (2019-10-05)
4
+ * add email format validation on string #51
5
+
3
6
  ## 0.5.0 (2019-09-28)
4
7
  * Add max and min length validators for string. #45
5
8
  * Support for minItems and maxItems in array #49
@@ -166,6 +166,17 @@ module OpenAPIParser
166
166
  end
167
167
  end
168
168
 
169
+ class InvalidEmailFormat < OpenAPIError
170
+ def initialize(value, reference)
171
+ super(reference)
172
+ @value = value
173
+ end
174
+
175
+ def message
176
+ "#{@value} is not a valid email address format in #{@reference}"
177
+ end
178
+ end
179
+
169
180
  class NotExistStatusCodeDefinition < OpenAPIError
170
181
  def message
171
182
  "don't exist status code definition in #{@reference}"
@@ -24,6 +24,9 @@ class OpenAPIParser::SchemaValidator
24
24
  value, err = validate_max_min_length(value, schema)
25
25
  return [nil, err] if err
26
26
 
27
+ value, err = validate_email_format(value, schema)
28
+ return [nil, err] if err
29
+
27
30
  [value, nil]
28
31
  end
29
32
 
@@ -61,5 +64,16 @@ class OpenAPIParser::SchemaValidator
61
64
 
62
65
  [value, nil]
63
66
  end
67
+
68
+ def validate_email_format(value, schema)
69
+ return [value, nil] unless schema.format == 'email'
70
+
71
+ # match? method is good performance.
72
+ # So when we drop ruby 2.3 support we use match? method because this method add ruby 2.4
73
+ #return [value, nil] if value.match?(URI::MailTo::EMAIL_REGEXP)
74
+ return [value, nil] if value.match(URI::MailTo::EMAIL_REGEXP)
75
+
76
+ return [nil, OpenAPIParser::InvalidEmailFormat.new(value, schema.object_reference)]
77
+ end
64
78
  end
65
79
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-28 00:00:00.000000000 Z
11
+ date: 2019-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler