dsl_compose 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f39f962fc5991e68164ab544ca3cb85b7f538296d393f360fdda683956c883bd
4
- data.tar.gz: d68a46d791c33ac1ed435d9be92490ebbd76b053f13d2ef5a17247caf245b148
3
+ metadata.gz: 44f916259ac32c44bb38f5c8a423d6e41f9c3b61604715bb1e550b1ab9f5dc64
4
+ data.tar.gz: 22a2303459feb386ac8fa0995323fa95001d2312e83d90271d0868f66cf69e82
5
5
  SHA512:
6
- metadata.gz: 97b3fdcdd3b2ded2028155a9a767fb9cacf8a0e39b00a3cf8e203290d78a7bdbce9119b0b2b856b82afb61c209e24025c9e94991dfa5abe7383f55efc69446e4
7
- data.tar.gz: 38d4eda779bb41af8300ce7d266307eb8fa58529bca51d9c9dcf1589ed1b11f535d4a0746ea359c18f56ca5aae30a13655d987bc0f3de06bf2bdc6f560701f82
6
+ metadata.gz: fcf694293406ec2b317da5a9ea7f9fcfac87efae1ecd8cf481e27325d916b61ffdb23b54909589d01cdbb2e30d1fc612c5f6bd7d6e1618e2db937bf97c43f052
7
+ data.tar.gz: a50c27fe9ffab7b47326c1e4826983fe0bcec1428fed0f2d5d7e0b54d928e5c592cba2d8973b88f11e08bcc295f50a6def76058de086d97fd14f98273c656019
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.0](https://github.com/craigulliott/dsl_compose/compare/v1.8.0...v1.9.0) (2023-07-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * start_with, not_start_with, end_with and not_end_with validators now accept an array of values to test against ([#23](https://github.com/craigulliott/dsl_compose/issues/23)) ([cddcb4b](https://github.com/craigulliott/dsl_compose/commit/cddcb4b629499e3af0d71cc27f5c2f1dd8ae76d5))
9
+
3
10
  ## [1.8.0](https://github.com/craigulliott/dsl_compose/compare/v1.7.0...v1.8.0) (2023-07-11)
4
11
 
5
12
 
data/README.md CHANGED
@@ -293,16 +293,16 @@ The following validations can be added to the arguments of your DSL methods. Val
293
293
  validate_in ["cat", "dog"]
294
294
 
295
295
  # The argument must start with the following string.
296
- validate_start_with ["foo_"]
296
+ validate_start_with [:foo_]
297
297
 
298
298
  # The argument must not start with the following string.
299
- validate_not_start_with ["foo_"]
299
+ validate_not_start_with [:foo_]
300
300
 
301
301
  # The argument must end with the following string.
302
- validate_end_with ["_foo"]
302
+ validate_end_with [:_foo]
303
303
 
304
304
  # The argument must not end with the following string.
305
- validate_not_end_with ["_foo"]
305
+ validate_not_end_with [:_foo]
306
306
 
307
307
  # The argument must match the provided regex.
308
308
  validate_format /\A[A-Z][a-z]+\Z/
@@ -340,16 +340,16 @@ The following validations can be added to the arguments of your DSL methods. Val
340
340
  validate_in [:cat, :dog]
341
341
 
342
342
  # The argument must start with the following string.
343
- validate_start_with ["foo_"]
343
+ validate_start_with [:foo_]
344
344
 
345
345
  # The argument must not start with the following string.
346
- validate_not_start_with ["foo_"]
346
+ validate_not_start_with [:foo_]
347
347
 
348
348
  # The argument must end with the following string.
349
- validate_end_with ["_foo"]
349
+ validate_end_with [:_foo]
350
350
 
351
351
  # The argument must not end with the following string.
352
- validate_not_end_with ["_foo"]
352
+ validate_not_end_with [:_foo]
353
353
 
354
354
  # The argument must match the provided regex.
355
355
  validate_format /\A[A-Z][a-z]+\Z/
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to end with `#{@value}`" unless value.end_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to end with `#{@values}`" unless @values.filter { |v| value.end_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not end with `#{@value}`" if value.end_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not end with `#{@values}`" if @values.filter { |v| value.end_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not start with `#{@value}`" if value.start_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not start with `#{@values}`" if @values.filter { |v| value.start_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to start with `#{@value}`" unless value.start_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to start with `#{@values}`" unless @values.filter { |v| value.start_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -260,7 +260,7 @@ module DSLCompose
260
260
  raise ValidationAlreadyExistsError, "The validation `end_with` has already been applied to this method option."
261
261
  end
262
262
 
263
- unless value.is_a? String
263
+ unless value.is_a? Symbol
264
264
  raise ValidationInvalidArgumentError, value
265
265
  end
266
266
 
@@ -276,7 +276,7 @@ module DSLCompose
276
276
  raise ValidationAlreadyExistsError, "The validation `not_end_with` has already been applied to this method option."
277
277
  end
278
278
 
279
- unless value.is_a? String
279
+ unless value.is_a? Symbol
280
280
  raise ValidationInvalidArgumentError, value
281
281
  end
282
282
 
@@ -292,7 +292,7 @@ module DSLCompose
292
292
  raise ValidationAlreadyExistsError, "The validation `start_with` has already been applied to this method option."
293
293
  end
294
294
 
295
- unless value.is_a? String
295
+ unless value.is_a? Symbol
296
296
  raise ValidationInvalidArgumentError, value
297
297
  end
298
298
 
@@ -308,7 +308,7 @@ module DSLCompose
308
308
  raise ValidationAlreadyExistsError, "The validation `not_start_with` has already been applied to this method option."
309
309
  end
310
310
 
311
- unless value.is_a? String
311
+ unless value.is_a? Symbol
312
312
  raise ValidationInvalidArgumentError, value
313
313
  end
314
314
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSLCompose
4
- VERSION = "1.8.0"
4
+ VERSION = "1.9.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott