liquid-validations 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/liquid-validations/version.rb +1 -1
- data/lib/liquid-validations.rb +3 -3
- data/spec/liquid_validations_spec.rb +3 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/liquid-validations.rb
CHANGED
@@ -16,7 +16,7 @@ module LiquidValidations
|
|
16
16
|
end
|
17
17
|
|
18
18
|
for error in errors
|
19
|
-
record.errors.add(
|
19
|
+
record.errors.add(:base, friendly_liquid_error(error) + " in your #{ friendly_attr_name(attr_name) }")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -35,9 +35,9 @@ module LiquidValidations
|
|
35
35
|
container_re = /<\s*#{ container }.*>.*#{ variable_re }.*<\/\s*#{ container }\s*>/im
|
36
36
|
|
37
37
|
if container.blank? && !(value =~ variable_re)
|
38
|
-
record.errors.add(
|
38
|
+
record.errors.add(:base, "You must include {{ #{ variable } }} in your #{ friendly_attr_name(attr_name) }")
|
39
39
|
elsif !container.blank? && !(value =~ container_re)
|
40
|
-
record.errors.add(
|
40
|
+
record.errors.add(:base, "You must include {{ #{ variable } }} inside the <#{ container }> tag of your #{ friendly_attr_name(attr_name) }")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -19,6 +19,7 @@ describe LiquidValidations do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
@mixin = Mixin.new
|
22
|
+
@mixin.errors.clear
|
22
23
|
end
|
23
24
|
|
24
25
|
[ ' {{ Bad liquid ',
|
@@ -33,7 +34,7 @@ describe LiquidValidations do
|
|
33
34
|
it 'should include the errors in the errors object' do
|
34
35
|
@mixin.content = '{{ unclosed variable '
|
35
36
|
@mixin.valid?
|
36
|
-
@mixin.errors.
|
37
|
+
@mixin.errors.full_messages.any? { |e| e == "Variable '{{' was not properly closed in your content" }.must_equal true
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -58,7 +59,7 @@ describe LiquidValidations do
|
|
58
59
|
it 'should include the errors in the errors object' do
|
59
60
|
@mixin.content = '{{ josh_is_not_awesome }}'
|
60
61
|
@mixin.valid?
|
61
|
-
@mixin.errors.
|
62
|
+
@mixin.errors.full_messages.any? { |e| e == "You must include {{ josh_is_awesome }} in your content" }.must_equal true
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid-validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Wigham
|