dsl_compose 2.4.0 → 2.5.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: 43cfe766f3e464ba7f5a22128e7f5155806f92686555aef5f2f06af2b58916af
4
- data.tar.gz: 999dc31a662af4684b2956a50c226aa596b345ece609d2b9ace058eea211f924
3
+ metadata.gz: 6b29a5bddf2a3f304e22318d9ef0d2f1dc9efbb195618b1b296f33affff3d4b0
4
+ data.tar.gz: 06141a53c94fdfa21265df75594b627e30dd37d13d2943e83dda5cad29de9de4
5
5
  SHA512:
6
- metadata.gz: 78b2add3e95f52ae184abb3d2a30f9218d966a8d44e378b72ea37c5ad2dfd6c3409f7a9cf08e4762d17cf717c2ff35c2f7da4ce5a28d8959eacbcf92c484c0db
7
- data.tar.gz: 7d4e1550f001a40d0665c6258eff2cd16d0052f209b1c6741a3252b0623f698345d8344014555153649dd705077dda8cc39d08531bb95bd5df4611cde257c156
6
+ metadata.gz: 8f605f57dbf60fb77e7633d4631d7c5423d9614e28cce18e9e05fcca637d0b35b49b1d71c504d50289d527019c48f5a0a96588ab9cb25ba5d1c651c4ae6570f8
7
+ data.tar.gz: 19619027a3a21f8506cd077a927a719284b378d5d4cb2f2f11d5264a487442c2f44da2a1780684603a0154348c89c2359459b776077380da8f3a1093a15a72b6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.5.0](https://github.com/craigulliott/dsl_compose/compare/v2.4.0...v2.5.0) (2023-08-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * you can call validators which accept arrays (such as `validate_in`) multiple times and they will be combined ([e1b4411](https://github.com/craigulliott/dsl_compose/commit/e1b441176768726cecd828e303781a57d4e36750))
9
+
3
10
  ## [2.4.0](https://github.com/craigulliott/dsl_compose/compare/v2.3.0...v2.4.0) (2023-07-31)
4
11
 
5
12
 
@@ -12,6 +12,11 @@ module DSLCompose
12
12
  end
13
13
 
14
14
  def initialize values
15
+ @values = []
16
+ add_values values
17
+ end
18
+
19
+ def add_values values
15
20
  # if the provided values is a symbol, then convert it to an array
16
21
  if values.is_a? Symbol
17
22
  values = [values]
@@ -27,7 +32,7 @@ module DSLCompose
27
32
  raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
33
  end
29
34
 
30
- @values = values
35
+ @values += values
31
36
  end
32
37
 
33
38
  def validate! value
@@ -12,11 +12,16 @@ module DSLCompose
12
12
  end
13
13
 
14
14
  def initialize values
15
+ @values = []
16
+ add_values values
17
+ end
18
+
19
+ def add_values values
15
20
  unless values.is_a?(Array)
16
21
  raise InvalidValueError, "The value `#{values}` provided to this validator must be of type Array"
17
22
  end
18
23
 
19
- @values = values
24
+ @values += values
20
25
  end
21
26
 
22
27
  def validate! value
@@ -12,6 +12,11 @@ module DSLCompose
12
12
  end
13
13
 
14
14
  def initialize values
15
+ @values = []
16
+ add_values values
17
+ end
18
+
19
+ def add_values values
15
20
  # if the provided values is a symbol, then convert it to an array
16
21
  if values.is_a? Symbol
17
22
  values = [values]
@@ -27,7 +32,7 @@ module DSLCompose
27
32
  raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
33
  end
29
34
 
30
- @values = values
35
+ @values += values
31
36
  end
32
37
 
33
38
  def validate! value
@@ -12,11 +12,16 @@ module DSLCompose
12
12
  end
13
13
 
14
14
  def initialize values
15
+ @values = []
16
+ add_values values
17
+ end
18
+
19
+ def add_values values
15
20
  unless values.is_a?(Array)
16
21
  raise InvalidValueError, "The value `#{values}` provided to this validator must be of type Array"
17
22
  end
18
23
 
19
- @values = values
24
+ @values += values
20
25
  end
21
26
 
22
27
  def validate! value
@@ -12,6 +12,11 @@ module DSLCompose
12
12
  end
13
13
 
14
14
  def initialize values
15
+ @values = []
16
+ add_values values
17
+ end
18
+
19
+ def add_values values
15
20
  # if the provided values is a symbol, then convert it to an array
16
21
  if values.is_a? Symbol
17
22
  values = [values]
@@ -27,7 +32,7 @@ module DSLCompose
27
32
  raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
33
  end
29
34
 
30
- @values = values
35
+ @values += values
31
36
  end
32
37
 
33
38
  def validate! value
@@ -12,6 +12,11 @@ module DSLCompose
12
12
  end
13
13
 
14
14
  def initialize values
15
+ @values = []
16
+ add_values values
17
+ end
18
+
19
+ def add_values values
15
20
  # if the provided values is a symbol, then convert it to an array
16
21
  if values.is_a? Symbol
17
22
  values = [values]
@@ -27,7 +32,7 @@ module DSLCompose
27
32
  raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
33
  end
29
34
 
30
- @values = values
35
+ @values += values
31
36
  end
32
37
 
33
38
  def validate! value
@@ -230,10 +230,6 @@ module DSLCompose
230
230
  end
231
231
 
232
232
  def validate_in values
233
- if @in_validation
234
- raise ValidationAlreadyExistsError, "The validation `in` has already been applied to this method option."
235
- end
236
-
237
233
  unless values.is_a? Array
238
234
  raise ValidationInvalidArgumentError, values
239
235
  end
@@ -242,14 +238,15 @@ module DSLCompose
242
238
  raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
243
239
  end
244
240
 
245
- @in_validation = InValidation.new values
241
+ # if this validation has already been applied, then add the values to the existing validation
242
+ if @in_validation
243
+ @in_validation.add_values values
244
+ else
245
+ @in_validation = InValidation.new values
246
+ end
246
247
  end
247
248
 
248
249
  def validate_not_in values
249
- if @not_in_validation
250
- raise ValidationAlreadyExistsError, "The validation `not_in` has already been applied to this method option."
251
- end
252
-
253
250
  unless values.is_a? Array
254
251
  raise ValidationInvalidArgumentError, values
255
252
  end
@@ -258,14 +255,15 @@ module DSLCompose
258
255
  raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
259
256
  end
260
257
 
261
- @not_in_validation = NotInValidation.new values
258
+ # if this validation has already been applied, then add the values to the existing validation
259
+ if @not_in_validation
260
+ @not_in_validation.add_values values
261
+ else
262
+ @not_in_validation = NotInValidation.new values
263
+ end
262
264
  end
263
265
 
264
266
  def validate_end_with value
265
- if @end_with_validation
266
- raise ValidationAlreadyExistsError, "The validation `end_with` has already been applied to this method option."
267
- end
268
-
269
267
  unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
270
268
  raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
271
269
  end
@@ -274,14 +272,15 @@ module DSLCompose
274
272
  raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
275
273
  end
276
274
 
277
- @end_with_validation = EndWithValidation.new value
275
+ # if this validation has already been applied, then add the values to the existing validation
276
+ if @end_with_validation
277
+ @end_with_validation.add_values value
278
+ else
279
+ @end_with_validation = EndWithValidation.new value
280
+ end
278
281
  end
279
282
 
280
283
  def validate_not_end_with value
281
- if @not_end_with_validation
282
- raise ValidationAlreadyExistsError, "The validation `not_end_with` has already been applied to this method option."
283
- end
284
-
285
284
  unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
286
285
  raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
287
286
  end
@@ -290,14 +289,15 @@ module DSLCompose
290
289
  raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
291
290
  end
292
291
 
293
- @not_end_with_validation = NotEndWithValidation.new value
292
+ # if this validation has already been applied, then add the values to the existing validation
293
+ if @not_end_with_validation
294
+ @not_end_with_validation.add_values value
295
+ else
296
+ @not_end_with_validation = NotEndWithValidation.new value
297
+ end
294
298
  end
295
299
 
296
300
  def validate_start_with value
297
- if @start_with_validation
298
- raise ValidationAlreadyExistsError, "The validation `start_with` has already been applied to this method option."
299
- end
300
-
301
301
  unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
302
302
  raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
303
303
  end
@@ -306,14 +306,15 @@ module DSLCompose
306
306
  raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
307
307
  end
308
308
 
309
- @start_with_validation = StartWithValidation.new value
309
+ # if this validation has already been applied, then add the values to the existing validation
310
+ if @start_with_validation
311
+ @start_with_validation.add_values value
312
+ else
313
+ @start_with_validation = StartWithValidation.new value
314
+ end
310
315
  end
311
316
 
312
317
  def validate_not_start_with value
313
- if @not_start_with_validation
314
- raise ValidationAlreadyExistsError, "The validation `not_start_with` has already been applied to this method option."
315
- end
316
-
317
318
  unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
318
319
  raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
319
320
  end
@@ -322,7 +323,12 @@ module DSLCompose
322
323
  raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
323
324
  end
324
325
 
325
- @not_start_with_validation = NotStartWithValidation.new value
326
+ # if this validation has already been applied, then add the values to the existing validation
327
+ if @not_start_with_validation
328
+ @not_start_with_validation.add_values value
329
+ else
330
+ @not_start_with_validation = NotStartWithValidation.new value
331
+ end
326
332
  end
327
333
 
328
334
  def validate_length maximum: nil, minimum: nil, is: nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSLCompose
4
- VERSION = "2.4.0"
4
+ VERSION = "2.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: class_spec_helper