Skip to content

Commit 0247395

Browse files
authored
Add not_equal Rule (#35)
1 parent 213c013 commit 0247395

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'size'
4+
5+
class MiniDefender::Rules::NotEqual < MiniDefender::Rules::Size
6+
def self.signature
7+
'not_equal'
8+
end
9+
10+
def passes?(attribute, value, validator)
11+
!super
12+
end
13+
14+
def message(attribute, value, validator)
15+
super.gsub('must', 'must not')
16+
end
17+
end

‎lib/mini_defender/rules/size.rb‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def passes?(attribute, value, validator)
3434

3535
def message(attribute, value, validator)
3636
case value
37-
when ActionDispatch::Http::UploadedFile
38-
"The file size must be equal to #{@size} bytes."
39-
when Numeric
40-
"The value must be equal to #{@size}."
41-
else
42-
"The value length must be equal to #{@size}."
37+
when ActionDispatch::Http::UploadedFile
38+
"The file size must be equal to #{@size} bytes."
39+
when Numeric
40+
"The value must be equal to #{@size}."
41+
else
42+
"The value length must be equal to #{@size}."
4343
end
4444
end
4545
end

‎lib/mini_defender/version.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module MiniDefender
4-
VERSION = "0.7.3"
4+
VERSION = "0.7.4"
55
end

0 commit comments

Comments
 (0)