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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/decoractors/valid.rb +13 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77c293e83b94b669afaface9f0dfc796c0f06140598373f62ea8f1aa65b0c223
4
- data.tar.gz: ea07f92cbe43425039d57e0b8bf69b7b7be909ceae978a269298a99a6dbb3fdf
3
+ metadata.gz: cd076c017dd1617fad69078fd02a02c83705e1a679416fb88f57b4e953fb3045
4
+ data.tar.gz: 2a8f32dccc56e100e01272dcf400f4391adc05f07c61533cb43f6ad673afbac2
5
5
  SHA512:
6
- metadata.gz: 686e5967bca53980bb1cfde3efcae0e2129d4c936df8a29842c269a9131b4da55e75d50c12d7ed8852db3f7572cf3ddf0c1b01afc30464aee7aab77a7ca9c5a6
7
- data.tar.gz: 33c3c8904fbed09f245d5d34551c81fce6208d248150621383d46647b97e908dcd18d9484286253a2cd77ee5285c06792282314996ae02823dbc5aed7c1603b3
6
+ metadata.gz: da259c6342357c42ca5d4c16ca9610470885b42529c8ee7466b5e3098473bf261ebf82f0d19abcaa24d99cdb93e0df7227a4368178ad3abf8a13efdf18d97b5a
7
+ data.tar.gz: f7c60aae3932a37917841fc26671d4c77f23dc7c0830770595083959d28e8a1d889cc30baa0c191665ac8383eeebf463412032fe697c6d210e50c4242572f655
@@ -4,7 +4,9 @@ module Validator
4
4
  def validate params={}
5
5
  lambda {|self_model, *args, &blk|
6
6
  # puts "Validate"
7
- check_validate = self_model.check_validate(*args, &blk) # check validation and return [true]/[false, errors]
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: '0'
273
+ version: 1.3.1
274
274
  requirements: []
275
275
  rubyforge_project:
276
276
  rubygems_version: 2.7.7