forest_admin_datasource_active_record 1.16.3 → 1.16.4
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54dfadb6341d5c8a0e5d728a28665b5b46d838c3828fd127d470f5841bb9e482
|
|
4
|
+
data.tar.gz: 3299a07a5a2f65e8a734d7866323e60c9687483bc9ba2e58267f98b6a3bd55c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe6942630100dda8b47f4771708c72163cdffe4bbce79b196fd6c34120db64cd69150769e2fb88ebcdb65c20e5ba0238dd9c434f6aa9516ef8bf9e74e54c34c9
|
|
7
|
+
data.tar.gz: edc0881b8ec4fc01e0aa745bb603c995ca9e40071f4414aa498aec93648d7bb3f0e01a4726374dc7e7b3ad64d0baaf9c53c0d6bf442b3760c6336ac161da9787
|
|
@@ -2,6 +2,7 @@ module ForestAdminDatasourceActiveRecord
|
|
|
2
2
|
class Collection < ForestAdminDatasourceToolkit::Collection
|
|
3
3
|
include Parser::Column
|
|
4
4
|
include Parser::Relation
|
|
5
|
+
include Parser::Validation
|
|
5
6
|
include ForestAdminDatasourceToolkit::Components::Query
|
|
6
7
|
|
|
7
8
|
attr_reader :model
|
|
@@ -66,8 +67,7 @@ module ForestAdminDatasourceActiveRecord
|
|
|
66
67
|
is_sortable: true,
|
|
67
68
|
default_value: column.default,
|
|
68
69
|
enum_values: get_enum_values(@model, column),
|
|
69
|
-
|
|
70
|
-
validation: []
|
|
70
|
+
validation: get_validations(column)
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
add_field(column_name, field)
|
|
@@ -19,7 +19,7 @@ module ForestAdminDatasourceActiveRecord
|
|
|
19
19
|
when ActiveModel::Validations::NumericalityValidator
|
|
20
20
|
validations = parse_numericality_validator(validator, validations)
|
|
21
21
|
when ActiveModel::Validations::LengthValidator
|
|
22
|
-
validations = parse_length_validator(validator, validations)
|
|
22
|
+
validations = parse_length_validator(column, validator, validations)
|
|
23
23
|
when ActiveModel::Validations::FormatValidator
|
|
24
24
|
validations = parse_format_validator(validator, validations)
|
|
25
25
|
end
|
|
@@ -36,11 +36,15 @@ module ForestAdminDatasourceActiveRecord
|
|
|
36
36
|
parsed_validations << { operator: Operators::GREATER_THAN, value: value }
|
|
37
37
|
when :less_than, :less_than_or_equal_to
|
|
38
38
|
parsed_validations << { operator: Operators::LESS_THAN, value: value }
|
|
39
|
+
when :allow_nil
|
|
40
|
+
parsed_validations << { operator: Operators::PRESENT } unless value
|
|
39
41
|
end
|
|
40
42
|
end
|
|
43
|
+
|
|
44
|
+
parsed_validations
|
|
41
45
|
end
|
|
42
46
|
|
|
43
|
-
def parse_length_validator(validator, parsed_validations)
|
|
47
|
+
def parse_length_validator(column, validator, parsed_validations)
|
|
44
48
|
return unless get_column_type(@model, column) == 'String'
|
|
45
49
|
|
|
46
50
|
validator.options.each do |option, value|
|
|
@@ -54,6 +58,8 @@ module ForestAdminDatasourceActiveRecord
|
|
|
54
58
|
parsed_validations << { operator: Operators::SHORTER_THAN, value: value }
|
|
55
59
|
end
|
|
56
60
|
end
|
|
61
|
+
|
|
62
|
+
parsed_validations
|
|
57
63
|
end
|
|
58
64
|
|
|
59
65
|
def parse_format_validator(validator, parsed_validations)
|