active_model_validators_ex 0.0.2 → 0.0.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 854badf7303345d29a041e94264d9db10b3157c7
|
4
|
+
data.tar.gz: 067a7ec5466cb199761cb861a4ef431e6a2dc53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d9a52f18b2251efb6985fb8aa303f5ccb3b26c60893452029044513059cb8423707ea0f193edff321c693e51b6130943170109957027292165bdfdc552c2203
|
7
|
+
data.tar.gz: 4e15babcff28e0ff909fc4fb6f5ff07cc3d102fab4836fce07cb3941a6c61f6c36d235e2b9fddee69a325fbb6f7a415d243821e8ba804f6e50b8200a98c54556
|
@@ -4,18 +4,19 @@ class TimeFormatValidator < ActiveModel::EachValidator
|
|
4
4
|
|
5
5
|
parsed_time = value.is_a?(Time) ? value : Time.parse(value.to_s)
|
6
6
|
|
7
|
-
previous_time = \
|
8
|
-
case options[:after].class.name
|
9
|
-
when 'Proc'
|
10
|
-
options[:after].call
|
11
|
-
when 'Time'
|
12
|
-
options[:after]
|
13
|
-
end
|
14
|
-
|
15
7
|
if !previous_time.nil? and parsed_time < previous_time
|
16
8
|
record.errors[attribute] << "invalid value, #{value} must be after #{previous_time}"
|
17
9
|
end
|
18
10
|
rescue StandardError => e
|
19
11
|
record.errors[attribute] << "invalid value, #{value} not valid for #{attribute}"
|
20
12
|
end
|
13
|
+
|
14
|
+
def previous_time
|
15
|
+
case options[:after].class.name
|
16
|
+
when 'Proc'
|
17
|
+
options[:after].call
|
18
|
+
when 'Time'
|
19
|
+
options[:after]
|
20
|
+
end
|
21
|
+
end
|
21
22
|
end
|