better_model 1.3.0 → 2.1.0

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.
@@ -10,18 +10,18 @@ module BetterModel
10
10
  # Esempio:
11
11
  # validatable do
12
12
  # # Validazioni base
13
- # validate :title, :content, presence: true
14
- # validate :email, format: { with: URI::MailTo::EMAIL_REGEXP }
13
+ # check :title, :content, presence: true
14
+ # check :email, format: { with: URI::MailTo::EMAIL_REGEXP }
15
15
  #
16
16
  # # Validazioni condizionali
17
17
  # validate_if :is_published? do
18
- # validate :published_at, presence: true
19
- # validate :author_id, presence: true
18
+ # check :published_at, presence: true
19
+ # check :author_id, presence: true
20
20
  # end
21
21
  #
22
22
  # # Validazioni condizionali negate
23
23
  # validate_unless :is_draft? do
24
- # validate :reviewer_id, presence: true
24
+ # check :reviewer_id, presence: true
25
25
  # end
26
26
  #
27
27
  # # Cross-field validations
@@ -54,11 +54,11 @@ module BetterModel
54
54
  # @param options [Hash] Opzioni di validazione (presence, format, etc.)
55
55
  #
56
56
  # @example
57
- # validate :title, :content, presence: true
58
- # validate :email, format: { with: URI::MailTo::EMAIL_REGEXP }
59
- # validate :age, numericality: { greater_than: 0 }
57
+ # check :title, :content, presence: true
58
+ # check :email, format: { with: URI::MailTo::EMAIL_REGEXP }
59
+ # check :age, numericality: { greater_than: 0 }
60
60
  #
61
- def validate(*fields, **options)
61
+ def check(*fields, **options)
62
62
  # Se siamo dentro un blocco condizionale, aggiungi alla condizione corrente
63
63
  if @current_conditional
64
64
  @current_conditional[:validations] << {
@@ -79,12 +79,12 @@ module BetterModel
79
79
  #
80
80
  # @example Con simbolo (metodo)
81
81
  # validate_if :is_published? do
82
- # validate :published_at, presence: true
82
+ # check :published_at, presence: true
83
83
  # end
84
84
  #
85
85
  # @example Con lambda
86
86
  # validate_if -> { status == "published" } do
87
- # validate :published_at, presence: true
87
+ # check :published_at, presence: true
88
88
  # end
89
89
  #
90
90
  def validate_if(condition, &block)
@@ -111,7 +111,7 @@ module BetterModel
111
111
  #
112
112
  # @example
113
113
  # validate_unless :is_draft? do
114
- # validate :reviewer_id, presence: true
114
+ # check :reviewer_id, presence: true
115
115
  # end
116
116
  #
117
117
  def validate_unless(condition, &block)
@@ -1,3 +1,3 @@
1
1
  module BetterModel
2
- VERSION = "1.3.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alessiobussolari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-31 00:00:00.000000000 Z
11
+ date: 2025-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.5.11
98
+ rubygems_version: 3.5.22
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Rails engine gem that extends ActiveRecord model functionality