forest_admin_datasource_active_record 1.0.0.pre.beta.99 → 1.0.0.pre.beta.100

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: fa38740c29e976e5e77dab844069e0a7f08b5452cbf27927f2a68fe23d642ef4
4
- data.tar.gz: 3914f0b615ccdd81030e40784cc2e6a5e7db8a23885ccd05ca70b1be7fd5d325
3
+ metadata.gz: d540677c18c0148e40a293b2637152a26b1edbb8cedd27b98e2a5dc510387b82
4
+ data.tar.gz: 383bdce8cd6e3315281cceb7122b54e5e35cff1f98b6bd0cf1a78a6844f1b39d
5
5
  SHA512:
6
- metadata.gz: e657ecd90b409599f8372f23bc9a36a5e027f610750eb9d3b20f497fe11e4fadb4b5c7c14166986efc4092dbe43d9823de19d54f298113126a0d4fdd5e8164de
7
- data.tar.gz: 5c793b95f0bb895587f981781621227572f9c9e8febe7c3cf44cc024272bea0038bcfb7d9969f0559cb6a97b9a8e40c1921060b7310bac932d311b83d8eac8cc
6
+ metadata.gz: 8c4e25cab0331ccbfdd50e7f68fbec1ce0dfe451785305b22e324065db1bcf37d684e6e6cfa9e9eb407576f0a5bbd500447eac53b3822a9df4300db96a152db0
7
+ data.tar.gz: 753a18908e92430d96acc521dc81d7d5208de4bfa286d3ef755c6a408af4f8b7ed5f3bdddb5edb8f41afae361712b87e7b6b65c86b3ff3bdb3c53c989cbe63ed
@@ -1,6 +1,7 @@
1
1
  module ForestAdminDatasourceActiveRecord
2
2
  module Parser
3
3
  module Validation
4
+ include ForestAdminDatasourceToolkit::Components::Query::ConditionTree
4
5
  def get_validations(column)
5
6
  validations = []
6
7
  # NOTICE: Do not consider validations if a before_validation Active Records
@@ -14,10 +15,7 @@ module ForestAdminDatasourceActiveRecord
14
15
 
15
16
  case validator
16
17
  when ActiveRecord::Validations::PresenceValidator
17
- validations << {
18
- type: 'is present',
19
- message: validator.options[:message]
20
- }
18
+ validations << { operator: Operators::PRESENT }
21
19
  when ActiveModel::Validations::NumericalityValidator
22
20
  validations = parse_numericality_validator(validator, validations)
23
21
  when ActiveModel::Validations::LengthValidator
@@ -35,17 +33,9 @@ module ForestAdminDatasourceActiveRecord
35
33
  validator.options.each do |option, value|
36
34
  case option
37
35
  when :greater_than, :greater_than_or_equal_to
38
- parsed_validations << {
39
- type: 'is greater than',
40
- value: value,
41
- message: validator.options[:message]
42
- }
36
+ parsed_validations << { operator: Operators::GREATER_THAN, value: value }
43
37
  when :less_than, :less_than_or_equal_to
44
- parsed_validations << {
45
- type: 'is less than',
46
- value: value,
47
- message: validator.options[:message]
48
- }
38
+ parsed_validations << { operator: Operators::LESS_THAN, value: value }
49
39
  end
50
40
  end
51
41
  end
@@ -56,28 +46,12 @@ module ForestAdminDatasourceActiveRecord
56
46
  validator.options.each do |option, value|
57
47
  case option
58
48
  when :minimum
59
- parsed_validations << {
60
- type: 'is longer than',
61
- value: value,
62
- message: validator.options[:message]
63
- }
49
+ parsed_validations << { operator: Operators::LONGER_THAN, value: value }
64
50
  when :maximum
65
- parsed_validations << {
66
- type: 'is shorter than',
67
- value: value,
68
- message: validator.options[:message]
69
- }
51
+ parsed_validations << { operator: Operators::SHORTER_THAN, value: value }
70
52
  when :is
71
- parsed_validations << {
72
- type: 'is longer than',
73
- value: value,
74
- message: validator.options[:message]
75
- }
76
- parsed_validations << {
77
- type: 'is shorter than',
78
- value: value,
79
- message: validator.options[:message]
80
- }
53
+ parsed_validations << { operator: Operators::LONGER_THAN, value: value }
54
+ parsed_validations << { operator: Operators::SHORTER_THAN, value: value }
81
55
  end
82
56
  end
83
57
  end
@@ -93,11 +67,7 @@ module ForestAdminDatasourceActiveRecord
93
67
  # NOTICE: Transform a Ruby regex into a JS one
94
68
  regex = regex.sub('\\A', '^').sub('\\Z', '$').sub('\\z', '$').gsub(/\n+|\s+/, '')
95
69
 
96
- parsed_validations << {
97
- type: 'is like',
98
- value: "/#{regex}/#{options}",
99
- message: validator.options[:message]
100
- }
70
+ parsed_validations << { operator: Operators::CONTAINS, value: "/#{regex}/#{options}" }
101
71
  end
102
72
  end
103
73
 
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceActiveRecord
2
- VERSION = "1.0.0-beta.99"
2
+ VERSION = "1.0.0-beta.100"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.99
4
+ version: 1.0.0.pre.beta.100
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: 2025-02-27 00:00:00.000000000 Z
12
+ date: 2025-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord