active_fields 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/README.md +633 -0
  4. data/app/models/active_fields/field/boolean.rb +10 -3
  5. data/app/models/active_fields/field/date.rb +10 -4
  6. data/app/models/active_fields/field/date_array.rb +12 -18
  7. data/app/models/active_fields/field/date_time.rb +77 -0
  8. data/app/models/active_fields/field/date_time_array.rb +61 -0
  9. data/app/models/active_fields/field/decimal.rb +35 -6
  10. data/app/models/active_fields/field/decimal_array.rb +28 -11
  11. data/app/models/active_fields/field/enum.rb +28 -9
  12. data/app/models/active_fields/field/enum_array.rb +29 -22
  13. data/app/models/active_fields/field/integer.rb +10 -4
  14. data/app/models/active_fields/field/integer_array.rb +12 -8
  15. data/app/models/active_fields/field/text.rb +10 -4
  16. data/app/models/active_fields/field/text_array.rb +14 -8
  17. data/app/models/concerns/active_fields/customizable_concern.rb +60 -51
  18. data/app/models/concerns/active_fields/field_array_concern.rb +25 -0
  19. data/app/models/concerns/active_fields/field_concern.rb +45 -24
  20. data/app/models/concerns/active_fields/value_concern.rb +32 -4
  21. data/db/migrate/20240229230000_create_active_fields_tables.rb +2 -2
  22. data/lib/active_fields/casters/base_caster.rb +8 -2
  23. data/lib/active_fields/casters/date_caster.rb +8 -6
  24. data/lib/active_fields/casters/date_time_array_caster.rb +19 -0
  25. data/lib/active_fields/casters/date_time_caster.rb +43 -0
  26. data/lib/active_fields/casters/decimal_caster.rb +10 -2
  27. data/lib/active_fields/casters/enum_array_caster.rb +13 -1
  28. data/lib/active_fields/casters/enum_caster.rb +15 -1
  29. data/lib/active_fields/casters/integer_caster.rb +2 -2
  30. data/lib/active_fields/config.rb +12 -1
  31. data/lib/active_fields/customizable_config.rb +1 -1
  32. data/lib/active_fields/has_active_fields.rb +1 -1
  33. data/lib/active_fields/validators/base_validator.rb +7 -3
  34. data/lib/active_fields/validators/boolean_validator.rb +2 -2
  35. data/lib/active_fields/validators/date_array_validator.rb +3 -3
  36. data/lib/active_fields/validators/date_time_array_validator.rb +26 -0
  37. data/lib/active_fields/validators/date_time_validator.rb +19 -0
  38. data/lib/active_fields/validators/date_validator.rb +3 -3
  39. data/lib/active_fields/validators/decimal_array_validator.rb +2 -2
  40. data/lib/active_fields/validators/decimal_validator.rb +2 -2
  41. data/lib/active_fields/validators/enum_array_validator.rb +3 -3
  42. data/lib/active_fields/validators/enum_validator.rb +3 -3
  43. data/lib/active_fields/validators/integer_array_validator.rb +2 -2
  44. data/lib/active_fields/validators/integer_validator.rb +2 -2
  45. data/lib/active_fields/validators/text_array_validator.rb +2 -2
  46. data/lib/active_fields/validators/text_validator.rb +2 -2
  47. data/lib/active_fields/version.rb +1 -1
  48. data/lib/active_fields.rb +4 -0
  49. data/lib/generators/active_fields/install/USAGE +5 -0
  50. data/lib/generators/active_fields/install/install_generator.rb +29 -0
  51. metadata +11 -16
@@ -3,11 +3,17 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class Date < ActiveFields.config.field_base_class
6
- store_accessor :options, :required, :min, :max
6
+ acts_as_active_field(
7
+ validator: {
8
+ class_name: "ActiveFields::Validators::DateValidator",
9
+ options: -> { { required: required?, min: min, max: max } },
10
+ },
11
+ caster: {
12
+ class_name: "ActiveFields::Casters::DateCaster",
13
+ },
14
+ )
7
15
 
8
- # attribute :required, :boolean, default: false
9
- # attribute :min, :date
10
- # attribute :max, :date
16
+ store_accessor :options, :required, :min, :max
11
17
 
12
18
  validates :required, exclusion: [nil]
13
19
  validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
@@ -3,27 +3,21 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class DateArray < ActiveFields.config.field_base_class
6
- store_accessor :options, :min_size, :max_size, :min, :max
6
+ acts_as_active_field(
7
+ array: true,
8
+ validator: {
9
+ class_name: "ActiveFields::Validators::DateArrayValidator",
10
+ options: -> { { min: min, max: max, min_size: min_size, max_size: max_size } },
11
+ },
12
+ caster: {
13
+ class_name: "ActiveFields::Casters::DateArrayCaster",
14
+ },
15
+ )
16
+
17
+ store_accessor :options, :min, :max
7
18
 
8
- # attribute :min_size, :integer
9
- # attribute :max_size, :integer
10
- # attribute :min, :date
11
- # attribute :max, :date
12
-
13
- validates :min_size, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
14
- validates :max_size, comparison: { greater_than_or_equal_to: ->(r) { r.min_size || 0 } }, allow_nil: true
15
19
  validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
16
20
 
17
- %i[min_size max_size].each do |column|
18
- define_method(column) do
19
- Casters::IntegerCaster.new.deserialize(super())
20
- end
21
-
22
- define_method(:"#{column}=") do |other|
23
- super(Casters::IntegerCaster.new.serialize(other))
24
- end
25
- end
26
-
27
21
  %i[min max].each do |column|
28
22
  define_method(column) do
29
23
  Casters::DateCaster.new.deserialize(super())
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveFields
4
+ module Field
5
+ class DateTime < ActiveFields.config.field_base_class
6
+ acts_as_active_field(
7
+ validator: {
8
+ class_name: "ActiveFields::Validators::DateTimeValidator",
9
+ options: -> { { required: required?, min: min, max: max } },
10
+ },
11
+ caster: {
12
+ class_name: "ActiveFields::Casters::DateTimeCaster",
13
+ options: -> { { precision: precision } },
14
+ },
15
+ )
16
+
17
+ store_accessor :options, :required, :min, :max, :precision
18
+
19
+ validates :required, exclusion: [nil]
20
+ validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
21
+ validates :precision,
22
+ comparison: { greater_than_or_equal_to: 0, less_than_or_equal_to: Casters::DateTimeCaster::MAX_PRECISION },
23
+ allow_nil: true
24
+
25
+ # If precision is set after attributes that depend on it, deserialization will work correctly,
26
+ # but an incorrect internal value may be saved in the DB.
27
+ # This callback reassigns the internal values of the attributes to ensure accuracy.
28
+ before_save :reapply_precision
29
+
30
+ %i[required].each do |column|
31
+ define_method(column) do
32
+ Casters::BooleanCaster.new.deserialize(super())
33
+ end
34
+
35
+ define_method(:"#{column}?") do
36
+ !!public_send(column)
37
+ end
38
+
39
+ define_method(:"#{column}=") do |other|
40
+ super(Casters::BooleanCaster.new.serialize(other))
41
+ end
42
+ end
43
+
44
+ %i[min max].each do |column|
45
+ define_method(column) do
46
+ Casters::DateTimeCaster.new(precision: precision).deserialize(super())
47
+ end
48
+
49
+ define_method(:"#{column}=") do |other|
50
+ super(Casters::DateTimeCaster.new(precision: precision).serialize(other))
51
+ end
52
+ end
53
+
54
+ %i[precision].each do |column|
55
+ define_method(column) do
56
+ Casters::IntegerCaster.new.deserialize(super())
57
+ end
58
+
59
+ define_method(:"#{column}=") do |other|
60
+ super(Casters::IntegerCaster.new.serialize(other))
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def set_defaults
67
+ self.required ||= false
68
+ end
69
+
70
+ def reapply_precision
71
+ self.min = min
72
+ self.max = max
73
+ self.default_value = default_value
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveFields
4
+ module Field
5
+ class DateTimeArray < ActiveFields.config.field_base_class
6
+ acts_as_active_field(
7
+ array: true,
8
+ validator: {
9
+ class_name: "ActiveFields::Validators::DateTimeArrayValidator",
10
+ options: -> { { min: min, max: max, min_size: min_size, max_size: max_size } },
11
+ },
12
+ caster: {
13
+ class_name: "ActiveFields::Casters::DateTimeArrayCaster",
14
+ options: -> { { precision: precision } },
15
+ },
16
+ )
17
+
18
+ store_accessor :options, :min, :max, :precision
19
+
20
+ validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
21
+ validates :precision,
22
+ comparison: { greater_than_or_equal_to: 0, less_than_or_equal_to: Casters::DateTimeCaster::MAX_PRECISION },
23
+ allow_nil: true
24
+
25
+ # If precision is set after attributes that depend on it, deserialization will work correctly,
26
+ # but an incorrect internal value may be saved in the DB.
27
+ # This callback reassigns the internal values of the attributes to ensure accuracy.
28
+ before_save :reapply_precision
29
+
30
+ %i[precision].each do |column|
31
+ define_method(column) do
32
+ Casters::IntegerCaster.new.deserialize(super())
33
+ end
34
+
35
+ define_method(:"#{column}=") do |other|
36
+ super(Casters::IntegerCaster.new.serialize(other))
37
+ end
38
+ end
39
+
40
+ %i[min max].each do |column|
41
+ define_method(column) do
42
+ Casters::DateTimeCaster.new(precision: precision).deserialize(super())
43
+ end
44
+
45
+ define_method(:"#{column}=") do |other|
46
+ super(Casters::DateTimeCaster.new(precision: precision).serialize(other))
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def set_defaults; end
53
+
54
+ def reapply_precision
55
+ self.min = min
56
+ self.max = max
57
+ self.default_value = default_value
58
+ end
59
+ end
60
+ end
61
+ end
@@ -3,14 +3,27 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class Decimal < ActiveFields.config.field_base_class
6
- store_accessor :options, :required, :min, :max
6
+ acts_as_active_field(
7
+ validator: {
8
+ class_name: "ActiveFields::Validators::DecimalValidator",
9
+ options: -> { { required: required?, min: min, max: max } },
10
+ },
11
+ caster: {
12
+ class_name: "ActiveFields::Casters::DecimalCaster",
13
+ options: -> { { precision: precision } },
14
+ },
15
+ )
7
16
 
8
- # attribute :required, :boolean, default: false
9
- # attribute :min, :decimal
10
- # attribute :max, :decimal
17
+ store_accessor :options, :required, :min, :max, :precision
11
18
 
12
19
  validates :required, exclusion: [nil]
13
20
  validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
21
+ validates :precision, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
22
+
23
+ # If precision is set after attributes that depend on it, deserialization will work correctly,
24
+ # but an incorrect internal value may be saved in the DB.
25
+ # This callback reassigns the internal values of the attributes to ensure accuracy.
26
+ before_save :reapply_precision
14
27
 
15
28
  %i[required].each do |column|
16
29
  define_method(column) do
@@ -28,11 +41,21 @@ module ActiveFields
28
41
 
29
42
  %i[min max].each do |column|
30
43
  define_method(column) do
31
- Casters::DecimalCaster.new.deserialize(super())
44
+ Casters::DecimalCaster.new(precision: precision).deserialize(super())
45
+ end
46
+
47
+ define_method(:"#{column}=") do |other|
48
+ super(Casters::DecimalCaster.new(precision: precision).serialize(other))
49
+ end
50
+ end
51
+
52
+ %i[precision].each do |column|
53
+ define_method(column) do
54
+ Casters::IntegerCaster.new.deserialize(super())
32
55
  end
33
56
 
34
57
  define_method(:"#{column}=") do |other|
35
- super(Casters::DecimalCaster.new.serialize(other))
58
+ super(Casters::IntegerCaster.new.serialize(other))
36
59
  end
37
60
  end
38
61
 
@@ -41,6 +64,12 @@ module ActiveFields
41
64
  def set_defaults
42
65
  self.required ||= false
43
66
  end
67
+
68
+ def reapply_precision
69
+ self.min = min
70
+ self.max = max
71
+ self.default_value = default_value
72
+ end
44
73
  end
45
74
  end
46
75
  end
@@ -3,18 +3,29 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class DecimalArray < ActiveFields.config.field_base_class
6
- store_accessor :options, :min_size, :max_size, :min, :max
6
+ acts_as_active_field(
7
+ array: true,
8
+ validator: {
9
+ class_name: "ActiveFields::Validators::DecimalArrayValidator",
10
+ options: -> { { min: min, max: max, min_size: min_size, max_size: max_size } },
11
+ },
12
+ caster: {
13
+ class_name: "ActiveFields::Casters::DecimalArrayCaster",
14
+ options: -> { { precision: precision } },
15
+ },
16
+ )
17
+
18
+ store_accessor :options, :min, :max, :precision
7
19
 
8
- # attribute :min_size, :integer
9
- # attribute :max_size, :integer
10
- # attribute :min, :decimal
11
- # attribute :max, :decimal
12
-
13
- validates :min_size, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
14
- validates :max_size, comparison: { greater_than_or_equal_to: ->(r) { r.min_size || 0 } }, allow_nil: true
15
20
  validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
21
+ validates :precision, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
22
+
23
+ # If precision is set after attributes that depend on it, deserialization will work correctly,
24
+ # but an incorrect internal value may be saved in the DB.
25
+ # This callback reassigns the internal values of the attributes to ensure accuracy.
26
+ before_save :reapply_precision
16
27
 
17
- %i[min_size max_size].each do |column|
28
+ %i[precision].each do |column|
18
29
  define_method(column) do
19
30
  Casters::IntegerCaster.new.deserialize(super())
20
31
  end
@@ -26,17 +37,23 @@ module ActiveFields
26
37
 
27
38
  %i[min max].each do |column|
28
39
  define_method(column) do
29
- Casters::DecimalCaster.new.deserialize(super())
40
+ Casters::DecimalCaster.new(precision: precision).deserialize(super())
30
41
  end
31
42
 
32
43
  define_method(:"#{column}=") do |other|
33
- super(Casters::DecimalCaster.new.serialize(other))
44
+ super(Casters::DecimalCaster.new(precision: precision).serialize(other))
34
45
  end
35
46
  end
36
47
 
37
48
  private
38
49
 
39
50
  def set_defaults; end
51
+
52
+ def reapply_precision
53
+ self.min = min
54
+ self.max = max
55
+ self.default_value = default_value
56
+ end
40
57
  end
41
58
  end
42
59
  end
@@ -3,10 +3,17 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class Enum < ActiveFields.config.field_base_class
6
- store_accessor :options, :required, :allowed_values
6
+ acts_as_active_field(
7
+ validator: {
8
+ class_name: "ActiveFields::Validators::EnumValidator",
9
+ options: -> { { required: required?, allowed_values: allowed_values } },
10
+ },
11
+ caster: {
12
+ class_name: "ActiveFields::Casters::EnumCaster",
13
+ },
14
+ )
7
15
 
8
- # attribute :required, :boolean, default: false
9
- # attribute :allowed_values, :string, array: true, default: []
16
+ store_accessor :options, :required, :allowed_values
10
17
 
11
18
  validates :required, exclusion: [nil]
12
19
  validate :validate_allowed_values
@@ -40,15 +47,27 @@ module ActiveFields
40
47
  def validate_allowed_values
41
48
  if allowed_values.nil?
42
49
  errors.add(:allowed_values, :blank)
43
- elsif allowed_values.is_a?(Array)
44
- if allowed_values.empty?
45
- errors.add(:allowed_values, :blank)
46
- elsif allowed_values.any? { !_1.is_a?(String) }
50
+ return false
51
+ end
52
+
53
+ unless allowed_values.is_a?(Array)
54
+ errors.add(:allowed_values, :invalid)
55
+ return false
56
+ end
57
+
58
+ if allowed_values.empty?
59
+ errors.add(:allowed_values, :blank)
60
+ return false
61
+ end
62
+
63
+ allowed_values.each do |value_element|
64
+ if value_element.blank?
47
65
  errors.add(:allowed_values, :invalid)
66
+ return false
48
67
  end
49
- else
50
- errors.add(:allowed_values, :invalid)
51
68
  end
69
+
70
+ true
52
71
  end
53
72
 
54
73
  def set_defaults
@@ -3,26 +3,21 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class EnumArray < ActiveFields.config.field_base_class
6
- store_accessor :options, :min_size, :max_size, :allowed_values
6
+ acts_as_active_field(
7
+ array: true,
8
+ validator: {
9
+ class_name: "ActiveFields::Validators::EnumArrayValidator",
10
+ options: -> { { allowed_values: allowed_values, min_size: min_size, max_size: max_size } },
11
+ },
12
+ caster: {
13
+ class_name: "ActiveFields::Casters::EnumArrayCaster",
14
+ },
15
+ )
7
16
 
8
- # attribute :min_size, :integer
9
- # attribute :max_size, :integer
10
- # attribute :allowed_values, :string, array: true, default: []
17
+ store_accessor :options, :allowed_values
11
18
 
12
- validates :min_size, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
13
- validates :max_size, comparison: { greater_than_or_equal_to: ->(r) { r.min_size || 0 } }, allow_nil: true
14
19
  validate :validate_allowed_values
15
20
 
16
- %i[min_size max_size].each do |column|
17
- define_method(column) do
18
- Casters::IntegerCaster.new.deserialize(super())
19
- end
20
-
21
- define_method(:"#{column}=") do |other|
22
- super(Casters::IntegerCaster.new.serialize(other))
23
- end
24
- end
25
-
26
21
  %i[allowed_values].each do |column|
27
22
  define_method(column) do
28
23
  Casters::TextArrayCaster.new.deserialize(super())
@@ -38,15 +33,27 @@ module ActiveFields
38
33
  def validate_allowed_values
39
34
  if allowed_values.nil?
40
35
  errors.add(:allowed_values, :blank)
41
- elsif allowed_values.is_a?(Array)
42
- if allowed_values.empty?
43
- errors.add(:allowed_values, :blank)
44
- elsif allowed_values.any? { !_1.is_a?(String) }
36
+ return false
37
+ end
38
+
39
+ unless allowed_values.is_a?(Array)
40
+ errors.add(:allowed_values, :invalid)
41
+ return false
42
+ end
43
+
44
+ if allowed_values.empty?
45
+ errors.add(:allowed_values, :blank)
46
+ return false
47
+ end
48
+
49
+ allowed_values.each do |value_element|
50
+ if value_element.blank?
45
51
  errors.add(:allowed_values, :invalid)
52
+ return false
46
53
  end
47
- else
48
- errors.add(:allowed_values, :invalid)
49
54
  end
55
+
56
+ true
50
57
  end
51
58
 
52
59
  def set_defaults
@@ -3,11 +3,17 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class Integer < ActiveFields.config.field_base_class
6
- store_accessor :options, :required, :min, :max
6
+ acts_as_active_field(
7
+ validator: {
8
+ class_name: "ActiveFields::Validators::IntegerValidator",
9
+ options: -> { { required: required?, min: min, max: max } },
10
+ },
11
+ caster: {
12
+ class_name: "ActiveFields::Casters::IntegerCaster",
13
+ },
14
+ )
7
15
 
8
- # attribute :required, :boolean, default: false
9
- # attribute :min, :integer
10
- # attribute :max, :integer
16
+ store_accessor :options, :required, :min, :max
11
17
 
12
18
  validates :required, exclusion: [nil]
13
19
  validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
@@ -3,18 +3,22 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class IntegerArray < ActiveFields.config.field_base_class
6
- store_accessor :options, :min_size, :max_size, :min, :max
6
+ acts_as_active_field(
7
+ array: true,
8
+ validator: {
9
+ class_name: "ActiveFields::Validators::IntegerArrayValidator",
10
+ options: -> { { min: min, max: max, min_size: min_size, max_size: max_size } },
11
+ },
12
+ caster: {
13
+ class_name: "ActiveFields::Casters::IntegerArrayCaster",
14
+ },
15
+ )
7
16
 
8
- # attribute :min_size, :integer
9
- # attribute :max_size, :integer
10
- # attribute :min, :integer
11
- # attribute :max, :integer
17
+ store_accessor :options, :min, :max
12
18
 
13
- validates :min_size, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
14
- validates :max_size, comparison: { greater_than_or_equal_to: ->(r) { r.min_size || 0 } }, allow_nil: true
15
19
  validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min
16
20
 
17
- %i[min_size max_size min max].each do |column|
21
+ %i[min max].each do |column|
18
22
  define_method(column) do
19
23
  Casters::IntegerCaster.new.deserialize(super())
20
24
  end
@@ -3,11 +3,17 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class Text < ActiveFields.config.field_base_class
6
- store_accessor :options, :required, :min_length, :max_length
6
+ acts_as_active_field(
7
+ validator: {
8
+ class_name: "ActiveFields::Validators::TextValidator",
9
+ options: -> { { required: required?, min_length: min_length, max_length: max_length } },
10
+ },
11
+ caster: {
12
+ class_name: "ActiveFields::Casters::TextCaster",
13
+ },
14
+ )
7
15
 
8
- # attribute :required, :boolean, default: false
9
- # attribute :min_length, :integer
10
- # attribute :max_length, :integer
16
+ store_accessor :options, :required, :min_length, :max_length
11
17
 
12
18
  validates :required, exclusion: [nil]
13
19
  validates :min_length, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
@@ -3,19 +3,25 @@
3
3
  module ActiveFields
4
4
  module Field
5
5
  class TextArray < ActiveFields.config.field_base_class
6
- store_accessor :options, :min_size, :max_size, :min_length, :max_length
6
+ acts_as_active_field(
7
+ array: true,
8
+ validator: {
9
+ class_name: "ActiveFields::Validators::TextArrayValidator",
10
+ options: -> do
11
+ { min_length: min_length, max_length: max_length, min_size: min_size, max_size: max_size }
12
+ end,
13
+ },
14
+ caster: {
15
+ class_name: "ActiveFields::Casters::TextArrayCaster",
16
+ },
17
+ )
7
18
 
8
- # attribute :min_size, :integer
9
- # attribute :max_size, :integer
10
- # attribute :min_length, :integer
11
- # attribute :max_length, :integer
19
+ store_accessor :options, :min_length, :max_length
12
20
 
13
- validates :min_size, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
14
- validates :max_size, comparison: { greater_than_or_equal_to: ->(r) { r.min_size || 0 } }, allow_nil: true
15
21
  validates :min_length, comparison: { greater_than_or_equal_to: 0 }, allow_nil: true
16
22
  validates :max_length, comparison: { greater_than_or_equal_to: ->(r) { r.min_length || 0 } }, allow_nil: true
17
23
 
18
- %i[min_size max_size min_length max_length].each do |column|
24
+ %i[min_length max_length].each do |column|
19
25
  define_method(column) do
20
26
  Casters::IntegerCaster.new.deserialize(super())
21
27
  end