light_form 0.0.5 → 0.0.6
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 +4 -4
- data/lib/light_form/property_methods.rb +12 -5
- data/lib/light_form/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9597a28e9e3f731a43a85decad5f11e955d9388
|
4
|
+
data.tar.gz: 822d5e8f7b73af2e7fcc75a459bc8ca65b8a9ece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ddd24343f88e82596363ae25e7801bfd51c4b19f95cec83df6ef1f5df6880600accfe6631f31ef6737580111c31ebf36d3c9d4d00ddbd16bb51b4f49dabd92b
|
7
|
+
data.tar.gz: 1a097f2c95930916766cc4555e49e8ce9e4ee94cfbe900e8df68582817899638391754484391b19e65986b343c3d9970eb47e0b4a006418ee55e50be63b8739e
|
@@ -73,26 +73,33 @@ module LightForm
|
|
73
73
|
self.class.config[:errors_overriden] == true
|
74
74
|
end
|
75
75
|
|
76
|
-
def valid?
|
77
|
-
|
76
|
+
def valid?(context = nil)
|
77
|
+
@errors = ActiveModel::Errors.new(self)
|
78
|
+
return [_check_validation, _valid_without_clear?(context)].all? unless errors_overriden?
|
78
79
|
@_errors = @errors
|
79
|
-
@errors ||= ActiveModel::Errors.new(self)
|
80
80
|
stored_method = method(:errors)
|
81
81
|
errors_method = -> { @errors }
|
82
82
|
define_singleton_method(:errors) { errors_method.call }
|
83
|
-
result, store, @_errors, @errors = [_check_validation,
|
83
|
+
result, store, @_errors, @errors = [_check_validation, _valid_without_clear?(context)].all?, @_errors, @errors, store
|
84
84
|
define_singleton_method(:errors) { stored_method.call }
|
85
85
|
result
|
86
86
|
end
|
87
87
|
|
88
88
|
private
|
89
89
|
|
90
|
+
def _valid_without_clear?(context = nil)
|
91
|
+
current_context, self.validation_context = validation_context, context
|
92
|
+
run_validations!
|
93
|
+
ensure
|
94
|
+
self.validation_context = current_context
|
95
|
+
end
|
96
|
+
|
90
97
|
def _validation_errors(obj)
|
91
98
|
obj.errors if obj.respond_to?(:valid?) && !obj.valid?
|
92
99
|
end
|
93
100
|
|
94
101
|
def _check_validation
|
95
|
-
@errors
|
102
|
+
@errors = ActiveModel::Errors.new(self)
|
96
103
|
properties = _properties.delete(_properties_sources.keys)
|
97
104
|
properties.each do |prop|
|
98
105
|
public_send(prop).tap do |subject|
|
data/lib/light_form/version.rb
CHANGED