ucasy 0.2.1 → 0.3.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: 29058478e94580310ea89c45c5531835040a19cbcc917692b1751320402e5347
4
- data.tar.gz: b9337d673be5c35c9b963c47c7c5ab511e1832971a6a2bc2ed04380900e4f43b
3
+ metadata.gz: b230ba6c9ded76335c71cf886425d842c55f32533d6c84779424faaa49badebe
4
+ data.tar.gz: f786ee4638a88d16bc8c1d537e1613e31c1865156a2bfe75cb5f7e835100e152
5
5
  SHA512:
6
- metadata.gz: 2744ea8225b49381136a444e2f0a3cf400280198e3448bc0e179fe045115c73b658ba15e3f116038466ffed3ca089d2c6f5cd0ba3c7a70969635ea8b3f50f74a
7
- data.tar.gz: b99d19a8c712b1c1cfc0ddfe3692e2eba0247d98661bcfb6a17f9247872300bb4fa9213579e68ee08b237740ef84c019258bb128531acfaafdb661336f278715
6
+ metadata.gz: 7c95a6eb700102d5c7b74f6fb6b25fe2f0543991ed1d94039e355d762ba663060666f9b8d64d2a2b366557650118ff013a6ec24335709dc775b6ee58190c14fd
7
+ data.tar.gz: 4c9ad3225f60229154df85415c2ea3345509a3fc02df37e6c18315345698a3d7e22816788bbb12d1ce969859755c229c7dbfdbbe9c08513f2d258cd58849c029
data/README.md CHANGED
@@ -102,6 +102,15 @@ class AuthenticateUser < UseCaseBase
102
102
  end
103
103
  ```
104
104
 
105
+ You can filter attributes. Only `context.login` and `context.password` will be validated in example below:
106
+
107
+ ```rb
108
+ class AuthenticateUser < UseCaseBase
109
+ validate(AuthenticateUserValidation, :login, :password)
110
+ ...
111
+ end
112
+ ```
113
+
105
114
  Adds a validation
106
115
 
107
116
  ```rb
data/lib/ucasy/base.rb CHANGED
@@ -10,11 +10,12 @@ module Ucasy
10
10
  new(context).perform
11
11
  end
12
12
 
13
- def validate(validator_class)
13
+ def validate(validator_class, *validator_attribute_keys)
14
14
  @validator_class = validator_class
15
+ @validator_attribute_keys = validator_attribute_keys
15
16
  end
16
17
 
17
- attr_reader :validator_class
18
+ attr_reader :validator_class, :validator_attribute_keys
18
19
 
19
20
  def required_attributes(*attributes)
20
21
  @required_attributes = attributes
@@ -51,7 +52,7 @@ module Ucasy
51
52
  def validate!
52
53
  return if self.class.validator_class.blank?
53
54
 
54
- validator = Validators::Validate.call(self.class.validator_class, context.to_h)
55
+ validator = Validators::Validate.call(self.class.validator_class, validator_attributes)
55
56
 
56
57
  if validator.valid?
57
58
  validator.to_context.each do |key, value|
@@ -62,6 +63,12 @@ module Ucasy
62
63
  end
63
64
  end
64
65
 
66
+ def validator_attributes
67
+ return context.to_h if self.class.validator_attribute_keys.blank?
68
+
69
+ context.to_h.slice(*self.class.validator_attribute_keys)
70
+ end
71
+
65
72
  def validate_required_attributes!
66
73
  Validators::RequiredAttributes.call(context, self.class._required_attributes, self.class)
67
74
  end
data/lib/ucasy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ucasy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucasy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lavenda Software
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-25 00:00:00.000000000 Z
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubygems_version: 3.5.21
63
+ rubygems_version: 3.5.23
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: Ucasy is just a quick test suite setup for Rails application