glia-errors 0.0.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -2
- data/README.md +14 -16
- data/gemfiles/dry_validation_v0.gemfile +1 -1
- data/gemfiles/dry_validation_v1.gemfile +1 -1
- data/glia-errors.gemspec +1 -1
- data/lib/glia/errors.rb +2 -1
- data/lib/glia/errors/client_errors.rb +212 -0
- data/lib/glia/errors/error.rb +7 -0
- data/lib/glia/errors/error_types.rb +13 -0
- data/lib/glia/errors/mapper.rb +42 -31
- data/lib/glia/errors/server_errors.rb +27 -0
- metadata +6 -11
- data/LICENSE +0 -21
- data/lib/glia/errors/validation_errors.rb +0 -115
- data/test_cases/invalid_format_error_case.json +0 -74
- data/test_cases/invalid_length_error_case.json +0 -106
- data/test_cases/invalid_number_error_case.json +0 -90
- data/test_cases/invalid_type_error_case.json +0 -98
- data/test_cases/invalid_value_error_case.json +0 -125
- data/test_cases/missing_value_error_case.json +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d627db5f7496b55539268de587762316d8d138ea0548ecd7abb5c7968fb4b1
|
4
|
+
data.tar.gz: f0894efd36f5e3013d9f3892e922ea5b7007e3a271595a262e9e97534d90923f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03af1bfefb0087f78f4ddfabe4575980167f03df92fc0aba83052a1aaed18a936b60b53b3d442deb1676f85007b47a9c86772f0581fc63e425417ec3c22235d7
|
7
|
+
data.tar.gz: dac6e22cc50535689a445ae0616c73b362bfdf75af9daf81c4d11f54034f7233da72e3bf00f1c4a203e649227b223e2d37025db91aa83d8e3dd22ca8474b1be3
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.7.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
ast (~> 2.4.1)
|
14
14
|
patience_diff (1.1.0)
|
15
15
|
trollop (~> 1.16)
|
16
|
-
prettier (0.
|
16
|
+
prettier (0.22.0)
|
17
17
|
rainbow (3.0.0)
|
18
18
|
rake (13.0.1)
|
19
19
|
regexp_parser (2.0.0)
|
@@ -58,10 +58,11 @@ GEM
|
|
58
58
|
|
59
59
|
PLATFORMS
|
60
60
|
ruby
|
61
|
+
x86_64-darwin-19
|
61
62
|
|
62
63
|
DEPENDENCIES
|
63
64
|
appraisal
|
64
|
-
prettier (~> 0.
|
65
|
+
prettier (~> 0.22)
|
65
66
|
rake (~> 13.0)
|
66
67
|
rspec (~> 3.10)
|
67
68
|
rubocop (~> 1.5)
|
data/README.md
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
-
# glia-errors
|
2
|
-
Glia REST API errors (WIP)
|
1
|
+
# glia-errors
|
3
2
|
|
4
|
-
|
3
|
+
Implements Glia errors in Ruby and provides utilities to easily construct them.
|
5
4
|
|
6
|
-
|
5
|
+
# Installation
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
```
|
8
|
+
$ gem install glia-errors
|
9
|
+
```
|
11
10
|
|
12
|
-
|
11
|
+
## Usage
|
13
12
|
|
14
|
-
|
13
|
+
### Require library
|
15
14
|
|
16
15
|
```ruby
|
17
16
|
require 'glia/errors'
|
18
17
|
```
|
19
18
|
|
20
|
-
|
19
|
+
### For Glia developers
|
21
20
|
|
22
|
-
|
21
|
+
#### Map from `dry-validation` result
|
23
22
|
|
24
23
|
Currently 2 `dry-validation` versions are supported:
|
25
24
|
* `v0` up to `0.13`
|
@@ -51,7 +50,7 @@ error = Glia::Errors.from_dry_validation_result(result, ERROR_MAP)
|
|
51
50
|
response = error.to_h
|
52
51
|
```
|
53
52
|
|
54
|
-
|
53
|
+
### For REST API integrators
|
55
54
|
|
56
55
|
```ruby
|
57
56
|
require 'uri'
|
@@ -63,7 +62,6 @@ url = URI('https://api.glia.com/engagement_requests')
|
|
63
62
|
|
64
63
|
http = Net::HTTP.new(url.host, url.port)
|
65
64
|
http.use_ssl = true
|
66
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
67
65
|
request = Net::HTTP::Post.new(url)
|
68
66
|
request["Accept"] = 'application/json'
|
69
67
|
request["Content-Type"] = 'application/json'
|
@@ -91,9 +89,9 @@ else
|
|
91
89
|
end
|
92
90
|
```
|
93
91
|
|
94
|
-
|
92
|
+
## Contributing
|
95
93
|
|
96
|
-
|
94
|
+
### Testing
|
97
95
|
|
98
96
|
Glia errors support multiple versions of `dry-validation` and tests are run against each supported major version.
|
99
97
|
Under the hood we use `Appraisal` gem which generals additional gemfiles for each of the versions.
|
@@ -116,7 +114,7 @@ To run tests only for `dry-validation` v0:
|
|
116
114
|
bundle exec rake test_dry_validation_v0
|
117
115
|
```
|
118
116
|
|
119
|
-
|
117
|
+
### Formatting
|
120
118
|
|
121
119
|
```
|
122
120
|
bundle exec rake format
|
data/glia-errors.gemspec
CHANGED
data/lib/glia/errors.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative './errors/error'
|
4
4
|
require_relative './errors/error_types'
|
5
|
-
require_relative './errors/
|
5
|
+
require_relative './errors/client_errors'
|
6
|
+
require_relative './errors/server_errors'
|
6
7
|
require_relative './errors/mapper'
|
7
8
|
|
8
9
|
module Glia
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Glia
|
4
|
+
module Errors
|
5
|
+
# rubocop:disable Style/Documentation
|
6
|
+
class InputValidationError < Error
|
7
|
+
def initialize(error_details:, message: nil)
|
8
|
+
super(
|
9
|
+
type: INPUT_VALIDATION_ERROR,
|
10
|
+
ref: "https://example.com/errors/#{INPUT_VALIDATION_ERROR}.html",
|
11
|
+
message: message,
|
12
|
+
error_details: error_details
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class InvalidNumberError < Error
|
18
|
+
def initialize(field:, message: nil)
|
19
|
+
super(
|
20
|
+
type: INVALID_NUMBER_ERROR,
|
21
|
+
ref: "https://example.com/errors/#{INVALID_NUMBER_ERROR}.html",
|
22
|
+
message: message || "#{humanize(field)} value is invalid"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class InvalidValueError < Error
|
28
|
+
def initialize(field:, message: nil)
|
29
|
+
super(
|
30
|
+
type: INVALID_VALUE_ERROR,
|
31
|
+
ref: "https://example.com/errors/#{INVALID_VALUE_ERROR}.html",
|
32
|
+
message: message || "#{humanize(field)} value is invalid"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class InvalidLengthError < Error
|
38
|
+
def initialize(field:, message: nil)
|
39
|
+
super(
|
40
|
+
type: INVALID_LENGTH_ERROR,
|
41
|
+
ref: "https://example.com/errors/#{INVALID_LENGTH_ERROR}.html",
|
42
|
+
message: message || "#{humanize(field)} length is invalid"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class InvalidFormatError < Error
|
48
|
+
class Formats
|
49
|
+
DATE_TIME = 'date_time'
|
50
|
+
DATE = 'date'
|
51
|
+
TIME = 'time'
|
52
|
+
UUID = 'uuid'
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(field:, format: nil, message: nil)
|
56
|
+
default_message =
|
57
|
+
format ? "has invalid format, required format is #{format}" : 'has invalid format'
|
58
|
+
super(
|
59
|
+
type: INVALID_FORMAT_ERROR,
|
60
|
+
ref: "https://example.com/errors/#{INVALID_FORMAT_ERROR}.html",
|
61
|
+
message: message || "#{humanize(field)} #{default_message}"
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class InvalidTypeError < Error
|
67
|
+
class Types
|
68
|
+
STRING = 'string'
|
69
|
+
INTEGER = 'integer'
|
70
|
+
NUMBER = 'number'
|
71
|
+
BOOLEAN = 'boolean'
|
72
|
+
ARRAY = 'array'
|
73
|
+
OBJECT = 'object'
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize(field:, type:, message: nil)
|
77
|
+
super(
|
78
|
+
type: INVALID_TYPE_ERROR,
|
79
|
+
ref: "https://example.com/errors/#{INVALID_TYPE_ERROR}.html",
|
80
|
+
message: message || "#{humanize(field)} must be of type #{type}",
|
81
|
+
error_details: { type: type }
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class MissingValueError < Error
|
87
|
+
def initialize(field:, message: nil)
|
88
|
+
super(
|
89
|
+
type: MISSING_VALUE_ERROR,
|
90
|
+
ref: "https://example.com/errors/#{MISSING_VALUE_ERROR}.html",
|
91
|
+
message: message || "#{humanize(field)} is missing"
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class UnknownError < Error
|
97
|
+
def initialize(field:, message: nil)
|
98
|
+
super(
|
99
|
+
type: UNKNOWN_ERROR,
|
100
|
+
ref: "https://example.com/errors/#{UNKNOWN_ERROR}.html",
|
101
|
+
message: message || "#{humanize(field)} validation failed with unknown error"
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class ResourceNotFoundError < Error
|
107
|
+
def initialize(resource:, message: nil)
|
108
|
+
assert_snake_case(resource)
|
109
|
+
|
110
|
+
super(
|
111
|
+
type: RESOURCE_NOT_FOUND_ERROR,
|
112
|
+
ref: "https://example.com/errors/#{RESOURCE_NOT_FOUND_ERROR}.html",
|
113
|
+
message: message || "#{humanize(resource)} not found",
|
114
|
+
error_details: { resource: resource }
|
115
|
+
)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class NotVerifiedError < Error
|
120
|
+
def initialize(resource:, message: nil)
|
121
|
+
assert_snake_case(resource)
|
122
|
+
|
123
|
+
super(
|
124
|
+
type: NOT_VERIFIED_ERROR,
|
125
|
+
ref: "https://example.com/errors/#{NOT_VERIFIED_ERROR}.html",
|
126
|
+
message: message || "#{humanize(resource)} is not verified",
|
127
|
+
error_details: { resource: resource }
|
128
|
+
)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
class RemainingAssociationError < Error
|
133
|
+
def initialize(resource:, associated_resource:, message: nil)
|
134
|
+
assert_snake_case(resource)
|
135
|
+
assert_snake_case(associated_resource)
|
136
|
+
|
137
|
+
default_message =
|
138
|
+
"cannot be modified/deleted because it is associated to one or more #{
|
139
|
+
humanize(associated_resource)
|
140
|
+
}(s)"
|
141
|
+
super(
|
142
|
+
type: REMAINING_ASSOCIATION_ERROR,
|
143
|
+
ref: "https://example.com/errors/#{REMAINING_ASSOCIATION_ERROR}.html",
|
144
|
+
message: message || "#{humanize(resource)} #{default_message}",
|
145
|
+
error_details: { resource: resource, associated_resource: associated_resource }
|
146
|
+
)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
class LimitExceededError < Error
|
151
|
+
def initialize(resource:, max:, message: nil)
|
152
|
+
assert_snake_case(resource)
|
153
|
+
|
154
|
+
super(
|
155
|
+
type: LIMIT_EXCEEDED_ERROR,
|
156
|
+
ref: "https://example.com/errors/#{LIMIT_EXCEEDED_ERROR}.html",
|
157
|
+
message: message || "#{humanize(resource)} count must not exceed #{max}",
|
158
|
+
error_details: { resource: resource, max: max }
|
159
|
+
)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
class ResourceAlreadyExistsError < Error
|
164
|
+
def initialize(resource:, message: nil)
|
165
|
+
assert_snake_case(resource)
|
166
|
+
|
167
|
+
super(
|
168
|
+
type: RESOURCE_ALREADY_EXISTS_ERROR,
|
169
|
+
ref: "https://example.com/errors/#{RESOURCE_ALREADY_EXISTS_ERROR}.html",
|
170
|
+
message: message || "#{humanize(resource)} already exists",
|
171
|
+
error_details: { resource: resource }
|
172
|
+
)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class InvalidResourceStateError < Error
|
177
|
+
def initialize(resource:, state:, message: nil)
|
178
|
+
assert_snake_case(resource)
|
179
|
+
assert_snake_case(state)
|
180
|
+
|
181
|
+
super(
|
182
|
+
type: INVALID_RESOURCE_STATE_ERROR,
|
183
|
+
ref: "https://example.com/errors/#{INVALID_RESOURCE_STATE_ERROR}.html",
|
184
|
+
message: message || "#{humanize(resource)} is in invalid state: #{state}",
|
185
|
+
error_details: { resource: resource, state: state }
|
186
|
+
)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class AuthorizationError < Error
|
191
|
+
def initialize(message: nil)
|
192
|
+
super(
|
193
|
+
type: AUTHORIZATION_ERROR,
|
194
|
+
ref: "https://example.com/errors/#{AUTHORIZATION_ERROR}.html",
|
195
|
+
message: message || 'You do not have permissions to perform the action'
|
196
|
+
)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class RecipientOptedOutError < Error
|
201
|
+
def initialize(message: nil)
|
202
|
+
super(
|
203
|
+
type: RECIPIENT_OPTED_OUT_ERROR,
|
204
|
+
ref:
|
205
|
+
'https://docs.glia.com/glia-dev/reference/webhooks#example-engagementrequestfailure-event-with-fail_error',
|
206
|
+
message: message || 'Recipient has opted out'
|
207
|
+
)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
# rubocop:enable Style/Documentation
|
211
|
+
end
|
212
|
+
end
|
data/lib/glia/errors/error.rb
CHANGED
@@ -4,6 +4,7 @@ module Glia
|
|
4
4
|
module Errors
|
5
5
|
# Base error
|
6
6
|
class Error
|
7
|
+
SNAKE_CASE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/.freeze
|
7
8
|
attr_reader :type, :ref, :message, :error_details
|
8
9
|
|
9
10
|
def initialize(type:, ref:, message: nil, error_details: nil)
|
@@ -46,6 +47,12 @@ module Glia
|
|
46
47
|
def humanize(value)
|
47
48
|
value.to_s.capitalize.gsub('_', ' ')
|
48
49
|
end
|
50
|
+
|
51
|
+
def assert_snake_case(value)
|
52
|
+
return if value.to_s.match(SNAKE_CASE_REGEX)
|
53
|
+
|
54
|
+
raise ArgumentError, "Expected '#{value}' to be in snake case"
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Glia
|
4
4
|
module Errors
|
5
|
+
# Client errors
|
5
6
|
INPUT_VALIDATION_ERROR = 'input_validation_error'
|
6
7
|
INVALID_TYPE_ERROR = 'invalid_type_error'
|
7
8
|
INVALID_NUMBER_ERROR = 'invalid_number_error'
|
@@ -10,5 +11,17 @@ module Glia
|
|
10
11
|
INVALID_LENGTH_ERROR = 'invalid_length_error'
|
11
12
|
MISSING_VALUE_ERROR = 'missing_value_error'
|
12
13
|
UNKNOWN_ERROR = 'unknown_error'
|
14
|
+
RESOURCE_NOT_FOUND_ERROR = 'resource_not_found_error'
|
15
|
+
NOT_VERIFIED_ERROR = 'not_verified_error'
|
16
|
+
REMAINING_ASSOCIATION_ERROR = 'remaining_association_error'
|
17
|
+
LIMIT_EXCEEDED_ERROR = 'limit_exceeded_error'
|
18
|
+
RESOURCE_ALREADY_EXISTS_ERROR = 'resource_already_exists_error'
|
19
|
+
INVALID_RESOURCE_STATE_ERROR = 'invalid_resource_state_error'
|
20
|
+
AUTHORIZATION_ERROR = 'authorization_error'
|
21
|
+
RECIPIENT_OPTED_OUT_ERROR = 'recipient_opted_out_error'
|
22
|
+
|
23
|
+
# Server errors
|
24
|
+
INTERNAL_SERVER_ERROR = 'internal_server_error'
|
25
|
+
SERVICE_UNAVAILABLE_ERROR = 'service_unavailable_error'
|
13
26
|
end
|
14
27
|
end
|
data/lib/glia/errors/mapper.rb
CHANGED
@@ -8,17 +8,18 @@ module Glia
|
|
8
8
|
lambda do |field, _value, message|
|
9
9
|
type =
|
10
10
|
case message
|
11
|
-
when 'must be an array'
|
11
|
+
when 'must be an array', 'must be Array'
|
12
12
|
InvalidTypeError::Types::ARRAY
|
13
|
-
when 'must be an integer'
|
13
|
+
when 'must be an integer', 'must be Integer'
|
14
14
|
InvalidTypeError::Types::INTEGER
|
15
|
-
when 'must be a number', 'must be a float', 'must be a decimal'
|
15
|
+
when 'must be a number', 'must be a float', 'must be a decimal', 'must be Float',
|
16
|
+
'must be BigDecimal'
|
16
17
|
InvalidTypeError::Types::NUMBER
|
17
|
-
when 'must be a hash'
|
18
|
+
when 'must be a hash', 'must be Hash'
|
18
19
|
InvalidTypeError::Types::OBJECT
|
19
|
-
when 'must be boolean'
|
20
|
+
when 'must be boolean', 'must be Boolean'
|
20
21
|
InvalidTypeError::Types::BOOLEAN
|
21
|
-
when 'must be a string'
|
22
|
+
when 'must be a string', 'must be String'
|
22
23
|
InvalidTypeError::Types::STRING
|
23
24
|
end
|
24
25
|
InvalidTypeError.new(field: field, type: type)
|
@@ -45,40 +46,44 @@ module Glia
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
InvalidFormatError::Formats::TIME
|
61
|
-
end
|
62
|
-
InvalidFormatError.new(field: field, format: format)
|
63
|
-
else
|
64
|
-
InvalidTypeError.new(field: field, type: InvalidTypeError::Types::STRING)
|
65
|
-
end
|
49
|
+
INVALID_DATE_FORMAT =
|
50
|
+
lambda do |field, _value, message|
|
51
|
+
format =
|
52
|
+
case message
|
53
|
+
when 'must be a date', 'must be Date'
|
54
|
+
InvalidFormatError::Formats::DATE
|
55
|
+
when 'must be a date time', 'must be DateTime'
|
56
|
+
InvalidFormatError::Formats::DATE_TIME
|
57
|
+
when 'must be a time', 'must be Time'
|
58
|
+
InvalidFormatError::Formats::TIME
|
59
|
+
end
|
60
|
+
InvalidFormatError.new(field: field, format: format)
|
66
61
|
end
|
67
62
|
|
68
63
|
ERROR_MAP = {
|
69
64
|
# InvalidTypeError
|
70
65
|
'must be an array' => INVALID_TYPE_ERROR,
|
66
|
+
'must be Array' => INVALID_TYPE_ERROR,
|
71
67
|
'must be an integer' => INVALID_TYPE_ERROR,
|
68
|
+
'must be Integer' => INVALID_TYPE_ERROR,
|
72
69
|
'must be a number' => INVALID_TYPE_ERROR,
|
73
70
|
'must be a float' => INVALID_TYPE_ERROR,
|
71
|
+
'must be Float' => INVALID_TYPE_ERROR,
|
74
72
|
'must be a decimal' => INVALID_TYPE_ERROR,
|
73
|
+
'must be BigDecimal' => INVALID_TYPE_ERROR,
|
75
74
|
'must be a hash' => INVALID_TYPE_ERROR,
|
75
|
+
'must be Hash' => INVALID_TYPE_ERROR,
|
76
76
|
'must be boolean' => INVALID_TYPE_ERROR,
|
77
|
+
'must be Boolean' => INVALID_TYPE_ERROR,
|
77
78
|
'must be a string' => INVALID_TYPE_ERROR,
|
78
|
-
'must be
|
79
|
-
'must be a date' => INVALID_DATE_FORMAT_OR_TYPE_ERROR,
|
80
|
-
'must be a time' => INVALID_DATE_FORMAT_OR_TYPE_ERROR,
|
79
|
+
'must be String' => INVALID_TYPE_ERROR,
|
81
80
|
# InvalidFormatError
|
81
|
+
'must be a date time' => INVALID_DATE_FORMAT,
|
82
|
+
'must be DateTime' => INVALID_DATE_FORMAT,
|
83
|
+
'must be a date' => INVALID_DATE_FORMAT,
|
84
|
+
'must be Date' => INVALID_DATE_FORMAT,
|
85
|
+
'must be a time' => INVALID_DATE_FORMAT,
|
86
|
+
'must be Time' => INVALID_DATE_FORMAT,
|
82
87
|
'is in invalid format' => INVALID_FORMAT_ERROR,
|
83
88
|
'is not a valid UUID' => INVALID_UUID_ERROR,
|
84
89
|
# InvalidNumberError
|
@@ -93,9 +98,11 @@ module Glia
|
|
93
98
|
'must be false' => INVALID_VALUE_ERROR,
|
94
99
|
'must include' => INVALID_VALUE_ERROR,
|
95
100
|
'must not include' => INVALID_VALUE_ERROR,
|
96
|
-
'must be
|
97
|
-
|
98
|
-
|
101
|
+
'must be filled' =>
|
102
|
+
lambda do |field, value, _message|
|
103
|
+
# Consider `nil` as invalid value error, but empty string or array as invalid length error
|
104
|
+
value.nil? ? InvalidValueError.new(field: field) : InvalidLengthError.new(field: field)
|
105
|
+
end,
|
99
106
|
'cannot be defined' => INVALID_VALUE_ERROR,
|
100
107
|
# InvalidNumberError or InvalidValueError
|
101
108
|
'must be equal to' => INVALID_NUMBER_OR_VALUE_ERROR,
|
@@ -112,6 +119,8 @@ module Glia
|
|
112
119
|
'bytes long' => INVALID_LENGTH_ERROR,
|
113
120
|
'length must be' => INVALID_LENGTH_ERROR,
|
114
121
|
'length must be within' => INVALID_LENGTH_ERROR,
|
122
|
+
'must be empty' => INVALID_LENGTH_ERROR,
|
123
|
+
'cannot be empty' => INVALID_LENGTH_ERROR,
|
115
124
|
# MissingValueError
|
116
125
|
'is missing' => MISSING_VALUE_ERROR,
|
117
126
|
# Custom format errors
|
@@ -132,7 +141,9 @@ module Glia
|
|
132
141
|
field_value = output[field]
|
133
142
|
acc[field] =
|
134
143
|
if field_messages.is_a?(Hash)
|
135
|
-
|
144
|
+
# Wrap result in array as by defined structure each field has an array of errors.
|
145
|
+
# This is not needed for the `else` case as dry-validation already provides an array.
|
146
|
+
[from_dry_validation_result_rec(field_value, field_messages, error_map)]
|
136
147
|
else
|
137
148
|
field_messages.map do |message|
|
138
149
|
from_dry_validation_error(field, field_value, message, error_map)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Glia
|
4
|
+
module Errors
|
5
|
+
# rubocop:disable Style/Documentation
|
6
|
+
class InternalServerError < Error
|
7
|
+
def initialize(message: nil)
|
8
|
+
super(
|
9
|
+
type: INTERNAL_SERVER_ERROR,
|
10
|
+
ref: "https://example.com/errors/#{INTERNAL_SERVER_ERROR}.html",
|
11
|
+
message: message || 'Internal server error'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ServiceUnavailableError < Error
|
17
|
+
def initialize(message: nil)
|
18
|
+
super(
|
19
|
+
type: SERVICE_UNAVAILABLE_ERROR,
|
20
|
+
ref: "https://example.com/errors/#{SERVICE_UNAVAILABLE_ERROR}.html",
|
21
|
+
message: message || 'Service unavailable'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# rubocop:enable Style/Documentation
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glia-errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|
@@ -22,27 +22,22 @@ files:
|
|
22
22
|
- ".prettierrc"
|
23
23
|
- ".rspec"
|
24
24
|
- ".rubocop.yml"
|
25
|
+
- ".ruby-version"
|
25
26
|
- ".travis.yml"
|
26
27
|
- Appraisals
|
27
28
|
- Gemfile
|
28
29
|
- Gemfile.lock
|
29
|
-
- LICENSE
|
30
30
|
- README.md
|
31
31
|
- Rakefile
|
32
32
|
- gemfiles/dry_validation_v0.gemfile
|
33
33
|
- gemfiles/dry_validation_v1.gemfile
|
34
34
|
- glia-errors.gemspec
|
35
35
|
- lib/glia/errors.rb
|
36
|
+
- lib/glia/errors/client_errors.rb
|
36
37
|
- lib/glia/errors/error.rb
|
37
38
|
- lib/glia/errors/error_types.rb
|
38
39
|
- lib/glia/errors/mapper.rb
|
39
|
-
- lib/glia/errors/
|
40
|
-
- test_cases/invalid_format_error_case.json
|
41
|
-
- test_cases/invalid_length_error_case.json
|
42
|
-
- test_cases/invalid_number_error_case.json
|
43
|
-
- test_cases/invalid_type_error_case.json
|
44
|
-
- test_cases/invalid_value_error_case.json
|
45
|
-
- test_cases/missing_value_error_case.json
|
40
|
+
- lib/glia/errors/server_errors.rb
|
46
41
|
homepage:
|
47
42
|
licenses:
|
48
43
|
- MIT
|
@@ -62,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
57
|
- !ruby/object:Gem::Version
|
63
58
|
version: '0'
|
64
59
|
requirements: []
|
65
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.1.4
|
66
61
|
signing_key:
|
67
62
|
specification_version: 4
|
68
63
|
summary: Glia REST API errors
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2020 Glia Inc.
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
@@ -1,115 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Glia
|
4
|
-
module Errors
|
5
|
-
# InputValidationError
|
6
|
-
class InputValidationError < Error
|
7
|
-
def initialize(error_details:, message: nil)
|
8
|
-
super(
|
9
|
-
type: INPUT_VALIDATION_ERROR,
|
10
|
-
ref: "https://example.com/errors/#{INPUT_VALIDATION_ERROR}.html",
|
11
|
-
message: message,
|
12
|
-
error_details: error_details
|
13
|
-
)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# InvalidNumberError
|
18
|
-
class InvalidNumberError < Error
|
19
|
-
def initialize(field:)
|
20
|
-
super(
|
21
|
-
type: INVALID_NUMBER_ERROR,
|
22
|
-
ref: "https://example.com/errors/#{INVALID_NUMBER_ERROR}.html",
|
23
|
-
message: "#{humanize(field)} is invalid"
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# InvalidValueError
|
29
|
-
class InvalidValueError < Error
|
30
|
-
def initialize(field:)
|
31
|
-
super(
|
32
|
-
type: INVALID_VALUE_ERROR,
|
33
|
-
ref: "https://example.com/errors/#{INVALID_VALUE_ERROR}.html",
|
34
|
-
message: "#{humanize(field)} is invalid"
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# InvalidLengthError
|
40
|
-
class InvalidLengthError < Error
|
41
|
-
def initialize(field:)
|
42
|
-
super(
|
43
|
-
type: INVALID_LENGTH_ERROR,
|
44
|
-
ref: "https://example.com/errors/#{INVALID_LENGTH_ERROR}.html",
|
45
|
-
message: "#{humanize(field)} length is invalid"
|
46
|
-
)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# InvalidFormatError
|
51
|
-
class InvalidFormatError < Error
|
52
|
-
class Formats
|
53
|
-
DATE_TIME = 'date_time'
|
54
|
-
DATE = 'date'
|
55
|
-
TIME = 'time'
|
56
|
-
UUID = 'uuid'
|
57
|
-
end
|
58
|
-
|
59
|
-
def initialize(field:, format: nil)
|
60
|
-
super(
|
61
|
-
type: INVALID_FORMAT_ERROR,
|
62
|
-
ref: "https://example.com/errors/#{INVALID_FORMAT_ERROR}.html",
|
63
|
-
message:
|
64
|
-
if format
|
65
|
-
"#{humanize(field)} has invalid format, required format is #{format}"
|
66
|
-
else
|
67
|
-
"#{humanize(field)} has invalid format"
|
68
|
-
end
|
69
|
-
)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# InvalidTypeError
|
74
|
-
class InvalidTypeError < Error
|
75
|
-
class Types
|
76
|
-
STRING = 'string'
|
77
|
-
INTEGER = 'integer'
|
78
|
-
NUMBER = 'number'
|
79
|
-
BOOLEAN = 'boolean'
|
80
|
-
ARRAY = 'array'
|
81
|
-
OBJECT = 'object'
|
82
|
-
end
|
83
|
-
|
84
|
-
def initialize(field:, type:)
|
85
|
-
super(
|
86
|
-
type: INVALID_TYPE_ERROR,
|
87
|
-
ref: "https://example.com/errors/#{INVALID_TYPE_ERROR}.html",
|
88
|
-
message: "#{humanize(field)} must be of type #{type}"
|
89
|
-
)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# MissingValueError
|
94
|
-
class MissingValueError < Error
|
95
|
-
def initialize(field:)
|
96
|
-
super(
|
97
|
-
type: MISSING_VALUE_ERROR,
|
98
|
-
ref: "https://example.com/errors/#{MISSING_VALUE_ERROR}.html",
|
99
|
-
message: "#{humanize(field)} is missing"
|
100
|
-
)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# UnknownError
|
105
|
-
class UnknownError < Error
|
106
|
-
def initialize(field:)
|
107
|
-
super(
|
108
|
-
type: UNKNOWN_ERROR,
|
109
|
-
ref: "https://example.com/errors/#{UNKNOWN_ERROR}.html",
|
110
|
-
message: "#{humanize(field)} validation failed with unknown error"
|
111
|
-
)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"input": {
|
3
|
-
"invalid_format_abc_regex": "defg",
|
4
|
-
"invalid_format_date": "not date",
|
5
|
-
"invalid_format_date_time": "not date time",
|
6
|
-
"invalid_format_time": "not time",
|
7
|
-
"invalid_format_uuid": "not uuid",
|
8
|
-
"invalid_format_e164": "not phone number",
|
9
|
-
"invalid_format_phone_extension": "not phone extension",
|
10
|
-
"invalid_format_email": "not email"
|
11
|
-
},
|
12
|
-
"expectation": {
|
13
|
-
"type": "input_validation_error",
|
14
|
-
"ref": "https://example.com/errors/input_validation_error.html",
|
15
|
-
"error_details": {
|
16
|
-
"invalid_format_abc_regex": [
|
17
|
-
{
|
18
|
-
"type": "invalid_format_error",
|
19
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
20
|
-
"message": "Invalid format abc regex has invalid format"
|
21
|
-
}
|
22
|
-
],
|
23
|
-
"invalid_format_date": [
|
24
|
-
{
|
25
|
-
"type": "invalid_format_error",
|
26
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
27
|
-
"message": "Invalid format date has invalid format, required format is date"
|
28
|
-
}
|
29
|
-
],
|
30
|
-
"invalid_format_date_time": [
|
31
|
-
{
|
32
|
-
"type": "invalid_format_error",
|
33
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
34
|
-
"message": "Invalid format date time has invalid format, required format is date_time"
|
35
|
-
}
|
36
|
-
],
|
37
|
-
"invalid_format_time": [
|
38
|
-
{
|
39
|
-
"type": "invalid_format_error",
|
40
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
41
|
-
"message": "Invalid format time has invalid format, required format is time"
|
42
|
-
}
|
43
|
-
],
|
44
|
-
"invalid_format_uuid": [
|
45
|
-
{
|
46
|
-
"type": "invalid_format_error",
|
47
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
48
|
-
"message": "Invalid format uuid has invalid format, required format is uuid"
|
49
|
-
}
|
50
|
-
],
|
51
|
-
"invalid_format_e164": [
|
52
|
-
{
|
53
|
-
"type": "invalid_format_error",
|
54
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
55
|
-
"message": "Invalid format e164 has invalid format"
|
56
|
-
}
|
57
|
-
],
|
58
|
-
"invalid_format_phone_extension": [
|
59
|
-
{
|
60
|
-
"type": "invalid_format_error",
|
61
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
62
|
-
"message": "Invalid format phone extension has invalid format"
|
63
|
-
}
|
64
|
-
],
|
65
|
-
"invalid_format_email": [
|
66
|
-
{
|
67
|
-
"type": "invalid_format_error",
|
68
|
-
"ref": "https://example.com/errors/invalid_format_error.html",
|
69
|
-
"message": "Invalid format email has invalid format"
|
70
|
-
}
|
71
|
-
]
|
72
|
-
}
|
73
|
-
}
|
74
|
-
}
|
@@ -1,106 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"input": {
|
3
|
-
"invalid_length_array_max_length_3": [1, 2, 3, 4],
|
4
|
-
"invalid_length_array_min_length_3": [1, 2],
|
5
|
-
"invalid_length_array_exact_length_3": [1, 2],
|
6
|
-
"invalid_length_array_range_length_1_2": [1, 2, 3],
|
7
|
-
"invalid_length_string_max_length_3": "abcd",
|
8
|
-
"invalid_length_string_min_length_3": "ab",
|
9
|
-
"invalid_length_string_exact_length_3": "ab",
|
10
|
-
"invalid_length_string_range_length_1_2": "abc",
|
11
|
-
"invalid_length_string_max_bytesize_3": "abcd",
|
12
|
-
"invalid_length_string_min_bytesize_3": "a",
|
13
|
-
"invalid_length_string_exact_bytesize_3": "ab",
|
14
|
-
"invalid_length_string_range_bytesize_1_2": "abc"
|
15
|
-
},
|
16
|
-
"expectation": {
|
17
|
-
"type": "input_validation_error",
|
18
|
-
"ref": "https://example.com/errors/input_validation_error.html",
|
19
|
-
"error_details": {
|
20
|
-
"invalid_length_array_max_length_3": [
|
21
|
-
{
|
22
|
-
"type": "invalid_length_error",
|
23
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
24
|
-
"message": "Invalid length array max length 3 length is invalid"
|
25
|
-
}
|
26
|
-
],
|
27
|
-
"invalid_length_array_min_length_3": [
|
28
|
-
{
|
29
|
-
"type": "invalid_length_error",
|
30
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
31
|
-
"message": "Invalid length array min length 3 length is invalid"
|
32
|
-
}
|
33
|
-
],
|
34
|
-
"invalid_length_array_exact_length_3": [
|
35
|
-
{
|
36
|
-
"type": "invalid_length_error",
|
37
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
38
|
-
"message": "Invalid length array exact length 3 length is invalid"
|
39
|
-
}
|
40
|
-
],
|
41
|
-
"invalid_length_array_range_length_1_2": [
|
42
|
-
{
|
43
|
-
"type": "invalid_length_error",
|
44
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
45
|
-
"message": "Invalid length array range length 1 2 length is invalid"
|
46
|
-
}
|
47
|
-
],
|
48
|
-
"invalid_length_string_max_length_3": [
|
49
|
-
{
|
50
|
-
"type": "invalid_length_error",
|
51
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
52
|
-
"message": "Invalid length string max length 3 length is invalid"
|
53
|
-
}
|
54
|
-
],
|
55
|
-
"invalid_length_string_min_length_3": [
|
56
|
-
{
|
57
|
-
"type": "invalid_length_error",
|
58
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
59
|
-
"message": "Invalid length string min length 3 length is invalid"
|
60
|
-
}
|
61
|
-
],
|
62
|
-
"invalid_length_string_exact_length_3": [
|
63
|
-
{
|
64
|
-
"type": "invalid_length_error",
|
65
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
66
|
-
"message": "Invalid length string exact length 3 length is invalid"
|
67
|
-
}
|
68
|
-
],
|
69
|
-
"invalid_length_string_range_length_1_2": [
|
70
|
-
{
|
71
|
-
"type": "invalid_length_error",
|
72
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
73
|
-
"message": "Invalid length string range length 1 2 length is invalid"
|
74
|
-
}
|
75
|
-
],
|
76
|
-
"invalid_length_string_max_bytesize_3": [
|
77
|
-
{
|
78
|
-
"type": "invalid_length_error",
|
79
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
80
|
-
"message": "Invalid length string max bytesize 3 length is invalid"
|
81
|
-
}
|
82
|
-
],
|
83
|
-
"invalid_length_string_min_bytesize_3": [
|
84
|
-
{
|
85
|
-
"type": "invalid_length_error",
|
86
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
87
|
-
"message": "Invalid length string min bytesize 3 length is invalid"
|
88
|
-
}
|
89
|
-
],
|
90
|
-
"invalid_length_string_exact_bytesize_3": [
|
91
|
-
{
|
92
|
-
"type": "invalid_length_error",
|
93
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
94
|
-
"message": "Invalid length string exact bytesize 3 length is invalid"
|
95
|
-
}
|
96
|
-
],
|
97
|
-
"invalid_length_string_range_bytesize_1_2": [
|
98
|
-
{
|
99
|
-
"type": "invalid_length_error",
|
100
|
-
"ref": "https://example.com/errors/invalid_length_error.html",
|
101
|
-
"message": "Invalid length string range bytesize 1 2 length is invalid"
|
102
|
-
}
|
103
|
-
]
|
104
|
-
}
|
105
|
-
}
|
106
|
-
}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"input": {
|
3
|
-
"invalid_number_less_than_10": 20,
|
4
|
-
"invalid_number_less_than_or_equal_10": 20,
|
5
|
-
"invalid_number_more_than_10": 5,
|
6
|
-
"invalid_number_more_than_or_equal_10": 5,
|
7
|
-
"invalid_number_equal_10": 5,
|
8
|
-
"invalid_number_not_equal_10": 10,
|
9
|
-
"invalid_number_one_of_1_2": 4,
|
10
|
-
"invalid_number_in_range_1_to_3": 4,
|
11
|
-
"invalid_number_even": 3,
|
12
|
-
"invalid_number_odd": 4
|
13
|
-
},
|
14
|
-
"expectation": {
|
15
|
-
"type": "input_validation_error",
|
16
|
-
"ref": "https://example.com/errors/input_validation_error.html",
|
17
|
-
"error_details": {
|
18
|
-
"invalid_number_less_than_10": [
|
19
|
-
{
|
20
|
-
"type": "invalid_number_error",
|
21
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
22
|
-
"message": "Invalid number less than 10 is invalid"
|
23
|
-
}
|
24
|
-
],
|
25
|
-
"invalid_number_less_than_or_equal_10": [
|
26
|
-
{
|
27
|
-
"type": "invalid_number_error",
|
28
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
29
|
-
"message": "Invalid number less than or equal 10 is invalid"
|
30
|
-
}
|
31
|
-
],
|
32
|
-
"invalid_number_more_than_10": [
|
33
|
-
{
|
34
|
-
"type": "invalid_number_error",
|
35
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
36
|
-
"message": "Invalid number more than 10 is invalid"
|
37
|
-
}
|
38
|
-
],
|
39
|
-
"invalid_number_more_than_or_equal_10": [
|
40
|
-
{
|
41
|
-
"type": "invalid_number_error",
|
42
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
43
|
-
"message": "Invalid number more than or equal 10 is invalid"
|
44
|
-
}
|
45
|
-
],
|
46
|
-
"invalid_number_equal_10": [
|
47
|
-
{
|
48
|
-
"type": "invalid_number_error",
|
49
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
50
|
-
"message": "Invalid number equal 10 is invalid"
|
51
|
-
}
|
52
|
-
],
|
53
|
-
"invalid_number_not_equal_10": [
|
54
|
-
{
|
55
|
-
"type": "invalid_number_error",
|
56
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
57
|
-
"message": "Invalid number not equal 10 is invalid"
|
58
|
-
}
|
59
|
-
],
|
60
|
-
"invalid_number_one_of_1_2": [
|
61
|
-
{
|
62
|
-
"type": "invalid_number_error",
|
63
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
64
|
-
"message": "Invalid number one of 1 2 is invalid"
|
65
|
-
}
|
66
|
-
],
|
67
|
-
"invalid_number_in_range_1_to_3": [
|
68
|
-
{
|
69
|
-
"type": "invalid_number_error",
|
70
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
71
|
-
"message": "Invalid number in range 1 to 3 is invalid"
|
72
|
-
}
|
73
|
-
],
|
74
|
-
"invalid_number_even": [
|
75
|
-
{
|
76
|
-
"type": "invalid_number_error",
|
77
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
78
|
-
"message": "Invalid number even is invalid"
|
79
|
-
}
|
80
|
-
],
|
81
|
-
"invalid_number_odd": [
|
82
|
-
{
|
83
|
-
"type": "invalid_number_error",
|
84
|
-
"ref": "https://example.com/errors/invalid_number_error.html",
|
85
|
-
"message": "Invalid number odd is invalid"
|
86
|
-
}
|
87
|
-
]
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"input": {
|
3
|
-
"invalid_type_array": 0,
|
4
|
-
"invalid_type_number": "str",
|
5
|
-
"invalid_type_object": 0,
|
6
|
-
"invalid_type_boolean": 0,
|
7
|
-
"invalid_type_integer": 0.0,
|
8
|
-
"invalid_type_float": 0,
|
9
|
-
"invalid_type_decimal": 0,
|
10
|
-
"invalid_type_date": 0,
|
11
|
-
"invalid_type_date_time": 0,
|
12
|
-
"invalid_type_time": 0,
|
13
|
-
"invalid_type_string": 0
|
14
|
-
},
|
15
|
-
"expectation": {
|
16
|
-
"type": "input_validation_error",
|
17
|
-
"ref": "https://example.com/errors/input_validation_error.html",
|
18
|
-
"error_details": {
|
19
|
-
"invalid_type_array": [
|
20
|
-
{
|
21
|
-
"type": "invalid_type_error",
|
22
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
23
|
-
"message": "Invalid type array must be of type array"
|
24
|
-
}
|
25
|
-
],
|
26
|
-
"invalid_type_number": [
|
27
|
-
{
|
28
|
-
"type": "invalid_type_error",
|
29
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
30
|
-
"message": "Invalid type number must be of type number"
|
31
|
-
}
|
32
|
-
],
|
33
|
-
"invalid_type_object": [
|
34
|
-
{
|
35
|
-
"type": "invalid_type_error",
|
36
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
37
|
-
"message": "Invalid type object must be of type object"
|
38
|
-
}
|
39
|
-
],
|
40
|
-
"invalid_type_boolean": [
|
41
|
-
{
|
42
|
-
"type": "invalid_type_error",
|
43
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
44
|
-
"message": "Invalid type boolean must be of type boolean"
|
45
|
-
}
|
46
|
-
],
|
47
|
-
"invalid_type_integer": [
|
48
|
-
{
|
49
|
-
"type": "invalid_type_error",
|
50
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
51
|
-
"message": "Invalid type integer must be of type integer"
|
52
|
-
}
|
53
|
-
],
|
54
|
-
"invalid_type_float": [
|
55
|
-
{
|
56
|
-
"type": "invalid_type_error",
|
57
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
58
|
-
"message": "Invalid type float must be of type number"
|
59
|
-
}
|
60
|
-
],
|
61
|
-
"invalid_type_decimal": [
|
62
|
-
{
|
63
|
-
"type": "invalid_type_error",
|
64
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
65
|
-
"message": "Invalid type decimal must be of type number"
|
66
|
-
}
|
67
|
-
],
|
68
|
-
"invalid_type_date": [
|
69
|
-
{
|
70
|
-
"type": "invalid_type_error",
|
71
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
72
|
-
"message": "Invalid type date must be of type string"
|
73
|
-
}
|
74
|
-
],
|
75
|
-
"invalid_type_date_time": [
|
76
|
-
{
|
77
|
-
"type": "invalid_type_error",
|
78
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
79
|
-
"message": "Invalid type date time must be of type string"
|
80
|
-
}
|
81
|
-
],
|
82
|
-
"invalid_type_time": [
|
83
|
-
{
|
84
|
-
"type": "invalid_type_error",
|
85
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
86
|
-
"message": "Invalid type time must be of type string"
|
87
|
-
}
|
88
|
-
],
|
89
|
-
"invalid_type_string": [
|
90
|
-
{
|
91
|
-
"type": "invalid_type_error",
|
92
|
-
"ref": "https://example.com/errors/invalid_type_error.html",
|
93
|
-
"message": "Invalid type string must be of type string"
|
94
|
-
}
|
95
|
-
]
|
96
|
-
}
|
97
|
-
}
|
98
|
-
}
|
@@ -1,125 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"input": {
|
3
|
-
"invalid_value_string_equal_abc": "defg",
|
4
|
-
"invalid_value_string_one_of_a_b_c": "d",
|
5
|
-
"invalid_value_string_not_equal_abc": "abc",
|
6
|
-
"invalid_value_string_not_one_of_a_b_c": "a",
|
7
|
-
"invalid_value_string_empty": "a",
|
8
|
-
"invalid_value_string_not_empty": "",
|
9
|
-
|
10
|
-
"invalid_value_boolean_equal_true": false,
|
11
|
-
"invalid_value_boolean_equal_false": true,
|
12
|
-
|
13
|
-
"invalid_value_array_includes_a": ["b"],
|
14
|
-
"invalid_value_array_excludes_a": ["a"],
|
15
|
-
"invalid_value_array_empty": ["a"],
|
16
|
-
"invalid_value_array_not_empty": [],
|
17
|
-
|
18
|
-
"invalid_value_null": "a",
|
19
|
-
"invalid_value_not_null": null
|
20
|
-
},
|
21
|
-
"expectation": {
|
22
|
-
"type": "input_validation_error",
|
23
|
-
"ref": "https://example.com/errors/input_validation_error.html",
|
24
|
-
"error_details": {
|
25
|
-
"invalid_value_string_equal_abc": [
|
26
|
-
{
|
27
|
-
"type": "invalid_value_error",
|
28
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
29
|
-
"message": "Invalid value string equal abc is invalid"
|
30
|
-
}
|
31
|
-
],
|
32
|
-
"invalid_value_string_one_of_a_b_c": [
|
33
|
-
{
|
34
|
-
"type": "invalid_value_error",
|
35
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
36
|
-
"message": "Invalid value string one of a b c is invalid"
|
37
|
-
}
|
38
|
-
],
|
39
|
-
"invalid_value_string_not_equal_abc": [
|
40
|
-
{
|
41
|
-
"type": "invalid_value_error",
|
42
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
43
|
-
"message": "Invalid value string not equal abc is invalid"
|
44
|
-
}
|
45
|
-
],
|
46
|
-
"invalid_value_string_not_one_of_a_b_c": [
|
47
|
-
{
|
48
|
-
"type": "invalid_value_error",
|
49
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
50
|
-
"message": "Invalid value string not one of a b c is invalid"
|
51
|
-
}
|
52
|
-
],
|
53
|
-
"invalid_value_string_empty": [
|
54
|
-
{
|
55
|
-
"type": "invalid_value_error",
|
56
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
57
|
-
"message": "Invalid value string empty is invalid"
|
58
|
-
}
|
59
|
-
],
|
60
|
-
"invalid_value_string_not_empty": [
|
61
|
-
{
|
62
|
-
"type": "invalid_value_error",
|
63
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
64
|
-
"message": "Invalid value string not empty is invalid"
|
65
|
-
}
|
66
|
-
],
|
67
|
-
"invalid_value_boolean_equal_true": [
|
68
|
-
{
|
69
|
-
"type": "invalid_value_error",
|
70
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
71
|
-
"message": "Invalid value boolean equal true is invalid"
|
72
|
-
}
|
73
|
-
],
|
74
|
-
"invalid_value_boolean_equal_false": [
|
75
|
-
{
|
76
|
-
"type": "invalid_value_error",
|
77
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
78
|
-
"message": "Invalid value boolean equal false is invalid"
|
79
|
-
}
|
80
|
-
],
|
81
|
-
"invalid_value_array_includes_a": [
|
82
|
-
{
|
83
|
-
"type": "invalid_value_error",
|
84
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
85
|
-
"message": "Invalid value array includes a is invalid"
|
86
|
-
}
|
87
|
-
],
|
88
|
-
"invalid_value_array_excludes_a": [
|
89
|
-
{
|
90
|
-
"type": "invalid_value_error",
|
91
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
92
|
-
"message": "Invalid value array excludes a is invalid"
|
93
|
-
}
|
94
|
-
],
|
95
|
-
"invalid_value_array_empty": [
|
96
|
-
{
|
97
|
-
"type": "invalid_value_error",
|
98
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
99
|
-
"message": "Invalid value array empty is invalid"
|
100
|
-
}
|
101
|
-
],
|
102
|
-
"invalid_value_array_not_empty": [
|
103
|
-
{
|
104
|
-
"type": "invalid_value_error",
|
105
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
106
|
-
"message": "Invalid value array not empty is invalid"
|
107
|
-
}
|
108
|
-
],
|
109
|
-
"invalid_value_null": [
|
110
|
-
{
|
111
|
-
"type": "invalid_value_error",
|
112
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
113
|
-
"message": "Invalid value null is invalid"
|
114
|
-
}
|
115
|
-
],
|
116
|
-
"invalid_value_not_null": [
|
117
|
-
{
|
118
|
-
"type": "invalid_value_error",
|
119
|
-
"ref": "https://example.com/errors/invalid_value_error.html",
|
120
|
-
"message": "Invalid value not null is invalid"
|
121
|
-
}
|
122
|
-
]
|
123
|
-
}
|
124
|
-
}
|
125
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"input": {},
|
3
|
-
"expectation": {
|
4
|
-
"type": "input_validation_error",
|
5
|
-
"ref": "https://example.com/errors/input_validation_error.html",
|
6
|
-
"error_details": {
|
7
|
-
"missing_value": [
|
8
|
-
{
|
9
|
-
"type": "missing_value_error",
|
10
|
-
"ref": "https://example.com/errors/missing_value_error.html",
|
11
|
-
"message": "Missing value is missing"
|
12
|
-
}
|
13
|
-
]
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|