blsk_ruby_core_api 0.1.1 → 0.1.2.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/decoractors/valid.rb +13 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd076c017dd1617fad69078fd02a02c83705e1a679416fb88f57b4e953fb3045
|
4
|
+
data.tar.gz: 2a8f32dccc56e100e01272dcf400f4391adc05f07c61533cb43f6ad673afbac2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da259c6342357c42ca5d4c16ca9610470885b42529c8ee7466b5e3098473bf261ebf82f0d19abcaa24d99cdb93e0df7227a4368178ad3abf8a13efdf18d97b5a
|
7
|
+
data.tar.gz: f7c60aae3932a37917841fc26671d4c77f23dc7c0830770595083959d28e8a1d889cc30baa0c191665ac8383eeebf463412032fe697c6d210e50c4242572f655
|
data/lib/decoractors/valid.rb
CHANGED
@@ -4,7 +4,9 @@ module Validator
|
|
4
4
|
def validate params={}
|
5
5
|
lambda {|self_model, *args, &blk|
|
6
6
|
# puts "Validate"
|
7
|
-
|
7
|
+
seed_model = args[0]
|
8
|
+
self_rest = args [1]
|
9
|
+
valid_result = self_model.check_validate(self_model, self_rest) # check validation and return [true]/[false, errors]
|
8
10
|
if check_validate[0]
|
9
11
|
true
|
10
12
|
else
|
@@ -13,6 +15,16 @@ module Validator
|
|
13
15
|
}
|
14
16
|
end
|
15
17
|
|
18
|
+
def check_validate(seed_model, self_rest)
|
19
|
+
errors = seed_model.class::ValidationSchema.call(seed_model.attributes_data).messages
|
20
|
+
if errors.empty?
|
21
|
+
[true]
|
22
|
+
else
|
23
|
+
errors_response = self_rest.seed_service.convert_errors_response(errors)
|
24
|
+
[false, errors_response, self_rest]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
16
28
|
def convert_errors_response(error_list)
|
17
29
|
errors = []
|
18
30
|
error_list.each do |key, value|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blsk_ruby_core_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
4
|
+
version: 0.1.2.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fusin Thang
|
@@ -268,9 +268,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
268
268
|
version: 2.3.0
|
269
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
270
|
requirements:
|
271
|
-
- - "
|
271
|
+
- - ">"
|
272
272
|
- !ruby/object:Gem::Version
|
273
|
-
version:
|
273
|
+
version: 1.3.1
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
276
|
rubygems_version: 2.7.7
|