forest_admin_datasource_toolkit 1.0.0.pre.beta.38 → 1.0.0.pre.beta.40
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d1644c6dbd5c74ceeaf4b1fad0f885380d2c064e8e27052c4051215c54d1ec6
|
4
|
+
data.tar.gz: 8620984de80b2ca0c452495bf84a389813932e23e3f9446925f8cd9c90fe25b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 231b56aa6f848a9c06c7dfe8b7d5ba5d3ac22150a8ce4a60d310270cff7d4058add55ec6b7cc0c0f77c11001bc038d3c7e42f9bf781b0efc5b9cc9e45ddf7b43
|
7
|
+
data.tar.gz: ca841388695d9c61c97c381429e710e723c39c57fdec4dda3662e6db95acb4361dab286f2268e3ca01be50de9cd576c54d21376b353527df97aafa5b484d87ae
|
@@ -16,8 +16,10 @@ module ForestAdminDatasourceToolkit
|
|
16
16
|
"Unexpected field type: '#{collection.name}.#{field}' (found '#{schema.type}' expected 'Column')"
|
17
17
|
end
|
18
18
|
|
19
|
-
values
|
20
|
-
|
19
|
+
if values.is_a?(Array)
|
20
|
+
values.each do |value|
|
21
|
+
validate_value(field, schema, value)
|
22
|
+
end
|
21
23
|
end
|
22
24
|
else
|
23
25
|
prefix = field[0, dot_index]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ForestAdminDatasourceToolkit
|
2
|
+
module Validations
|
3
|
+
class RecordValidator
|
4
|
+
include ForestAdminDatasourceToolkit::Exceptions
|
5
|
+
|
6
|
+
def self.validate(collection, record_data)
|
7
|
+
raise ForestException, 'The record data is empty' if !record_data || record_data.empty?
|
8
|
+
|
9
|
+
record_data.each_key do |key|
|
10
|
+
schema = collection.schema[:fields][key]
|
11
|
+
|
12
|
+
if !schema
|
13
|
+
raise ForestException, "Unknown field #{key}"
|
14
|
+
elsif schema.type == 'Column'
|
15
|
+
FieldValidator.validate(collection, key, record_data[key])
|
16
|
+
elsif schema.type == 'OneToOne' || schema.type == 'ManyToOne'
|
17
|
+
sub_record = record_data[key]
|
18
|
+
association = collection.datasource.get_collection(schema.foreign_collection)
|
19
|
+
RecordValidator.validate(association, sub_record)
|
20
|
+
else
|
21
|
+
raise ForestException, "Unexpected schema type '#{schema.type}' while traversing record"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_admin_datasource_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.beta.
|
4
|
+
version: 1.0.0.pre.beta.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/forest_admin_datasource_toolkit/validations/condition_tree_validator.rb
|
107
107
|
- lib/forest_admin_datasource_toolkit/validations/field_validator.rb
|
108
108
|
- lib/forest_admin_datasource_toolkit/validations/projection_validator.rb
|
109
|
+
- lib/forest_admin_datasource_toolkit/validations/record_validator.rb
|
109
110
|
- lib/forest_admin_datasource_toolkit/validations/rules.rb
|
110
111
|
- lib/forest_admin_datasource_toolkit/validations/sort_validator.rb
|
111
112
|
- lib/forest_admin_datasource_toolkit/validations/type_getter.rb
|