activemodel 6.0.4 → 6.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +58 -183
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/active_model.rb +2 -1
  6. data/lib/active_model/attribute.rb +18 -17
  7. data/lib/active_model/attribute_assignment.rb +3 -4
  8. data/lib/active_model/attribute_methods.rb +74 -38
  9. data/lib/active_model/attribute_mutation_tracker.rb +8 -5
  10. data/lib/active_model/attribute_set.rb +18 -16
  11. data/lib/active_model/attribute_set/builder.rb +80 -13
  12. data/lib/active_model/attributes.rb +20 -24
  13. data/lib/active_model/callbacks.rb +1 -1
  14. data/lib/active_model/dirty.rb +17 -4
  15. data/lib/active_model/error.rb +207 -0
  16. data/lib/active_model/errors.rb +316 -208
  17. data/lib/active_model/gem_version.rb +1 -1
  18. data/lib/active_model/lint.rb +1 -1
  19. data/lib/active_model/naming.rb +2 -2
  20. data/lib/active_model/nested_error.rb +22 -0
  21. data/lib/active_model/railtie.rb +1 -1
  22. data/lib/active_model/secure_password.rb +14 -14
  23. data/lib/active_model/serialization.rb +9 -6
  24. data/lib/active_model/serializers/json.rb +7 -0
  25. data/lib/active_model/type/date_time.rb +2 -2
  26. data/lib/active_model/type/float.rb +2 -0
  27. data/lib/active_model/type/helpers/accepts_multiparameter_time.rb +11 -7
  28. data/lib/active_model/type/helpers/numeric.rb +8 -3
  29. data/lib/active_model/type/helpers/time_value.rb +27 -17
  30. data/lib/active_model/type/helpers/timezone.rb +1 -1
  31. data/lib/active_model/type/immutable_string.rb +14 -10
  32. data/lib/active_model/type/integer.rb +11 -2
  33. data/lib/active_model/type/registry.rb +5 -0
  34. data/lib/active_model/type/string.rb +12 -2
  35. data/lib/active_model/type/value.rb +9 -1
  36. data/lib/active_model/validations.rb +6 -6
  37. data/lib/active_model/validations/absence.rb +1 -1
  38. data/lib/active_model/validations/acceptance.rb +1 -1
  39. data/lib/active_model/validations/callbacks.rb +15 -15
  40. data/lib/active_model/validations/clusivity.rb +5 -1
  41. data/lib/active_model/validations/confirmation.rb +2 -2
  42. data/lib/active_model/validations/exclusion.rb +1 -1
  43. data/lib/active_model/validations/format.rb +2 -2
  44. data/lib/active_model/validations/inclusion.rb +1 -1
  45. data/lib/active_model/validations/length.rb +2 -2
  46. data/lib/active_model/validations/numericality.rb +54 -41
  47. data/lib/active_model/validations/presence.rb +1 -1
  48. data/lib/active_model/validations/validates.rb +6 -4
  49. data/lib/active_model/validator.rb +7 -1
  50. metadata +9 -7
@@ -85,7 +85,7 @@ module ActiveModel
85
85
  #
86
86
  # It can be useful to access the class that is using that validator when there are prerequisites such
87
87
  # as an +attr_accessor+ being present. This class is accessible via <tt>options[:class]</tt> in the constructor.
88
- # To setup your validator override the constructor.
88
+ # To set up your validator override the constructor.
89
89
  #
90
90
  # class MyValidator < ActiveModel::Validator
91
91
  # def initialize(options={})
@@ -149,6 +149,7 @@ module ActiveModel
149
149
  attributes.each do |attribute|
150
150
  value = record.read_attribute_for_validation(attribute)
151
151
  next if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank])
152
+ value = prepare_value_for_validation(value, record, attribute)
152
153
  validate_each(record, attribute, value)
153
154
  end
154
155
  end
@@ -164,6 +165,11 @@ module ActiveModel
164
165
  # +ArgumentError+ when invalid options are supplied.
165
166
  def check_validity!
166
167
  end
168
+
169
+ private
170
+ def prepare_value_for_validation(value, record, attr_name)
171
+ value
172
+ end
167
173
  end
168
174
 
169
175
  # +BlockValidator+ is a special +EachValidator+ which receives a block on initialization
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.4
4
+ version: 6.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.4
19
+ version: 6.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.0.4
26
+ version: 6.1.4
27
27
  description: A toolkit for building modeling frameworks like Active Record. Rich support
28
28
  for attributes, callbacks, validations, serialization, internationalization, and
29
29
  testing.
@@ -48,6 +48,7 @@ files:
48
48
  - lib/active_model/callbacks.rb
49
49
  - lib/active_model/conversion.rb
50
50
  - lib/active_model/dirty.rb
51
+ - lib/active_model/error.rb
51
52
  - lib/active_model/errors.rb
52
53
  - lib/active_model/forbidden_attributes_protection.rb
53
54
  - lib/active_model/gem_version.rb
@@ -55,6 +56,7 @@ files:
55
56
  - lib/active_model/locale/en.yml
56
57
  - lib/active_model/model.rb
57
58
  - lib/active_model/naming.rb
59
+ - lib/active_model/nested_error.rb
58
60
  - lib/active_model/railtie.rb
59
61
  - lib/active_model/secure_password.rb
60
62
  - lib/active_model/serialization.rb
@@ -102,10 +104,10 @@ licenses:
102
104
  - MIT
103
105
  metadata:
104
106
  bug_tracker_uri: https://github.com/rails/rails/issues
105
- changelog_uri: https://github.com/rails/rails/blob/v6.0.4/activemodel/CHANGELOG.md
106
- documentation_uri: https://api.rubyonrails.org/v6.0.4/
107
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.4/activemodel/CHANGELOG.md
108
+ documentation_uri: https://api.rubyonrails.org/v6.1.4/
107
109
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
108
- source_code_uri: https://github.com/rails/rails/tree/v6.0.4/activemodel
110
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.4/activemodel
109
111
  post_install_message:
110
112
  rdoc_options: []
111
113
  require_paths: