Class: MiniDefender::Rule
- Inherits:
-
Object
- Object
- MiniDefender::Rule
show all
- Defined in:
- lib/mini_defender/rule.rb
Direct Known Subclasses
MiniDefender::Rules::Accepted, MiniDefender::Rules::Alpha, MiniDefender::Rules::AlphaDash, MiniDefender::Rules::AlphaNum, MiniDefender::Rules::Array, MiniDefender::Rules::Bail, MiniDefender::Rules::Between, MiniDefender::Rules::Boolean, MiniDefender::Rules::Confirmed, MiniDefender::Rules::CountryCode, MiniDefender::Rules::Currency, MiniDefender::Rules::Date, MiniDefender::Rules::DateEq, MiniDefender::Rules::DateFormat, MiniDefender::Rules::Declined, MiniDefender::Rules::Default, MiniDefender::Rules::Different, MiniDefender::Rules::Digits, MiniDefender::Rules::DigitsBetween, MiniDefender::Rules::Distinct, MiniDefender::Rules::Email, MiniDefender::Rules::EndingWith, MiniDefender::Rules::Excluded, MiniDefender::Rules::ExcludedIf, MiniDefender::Rules::ExcludedUnless, MiniDefender::Rules::ExcludedWith, MiniDefender::Rules::ExcludedWithout, MiniDefender::Rules::Exists, MiniDefender::Rules::ExpiryDate, MiniDefender::Rules::ExpiryMonth, MiniDefender::Rules::ExpiryYear, MiniDefender::Rules::File, MiniDefender::Rules::Filled, MiniDefender::Rules::Hash, MiniDefender::Rules::Hostname, MiniDefender::Rules::Iban, MiniDefender::Rules::Image, MiniDefender::Rules::In, MiniDefender::Rules::InField, MiniDefender::Rules::Integer, MiniDefender::Rules::Ip, MiniDefender::Rules::Ipv4, MiniDefender::Rules::Ipv6, MiniDefender::Rules::Json, MiniDefender::Rules::Luhn, MiniDefender::Rules::MacAddress, MiniDefender::Rules::MaxDigits, MiniDefender::Rules::MerchantCategoryCode, MiniDefender::Rules::MimeTypes, MiniDefender::Rules::MinDigits, MiniDefender::Rules::NotEndingWith, MiniDefender::Rules::NotIn, MiniDefender::Rules::NotRegex, MiniDefender::Rules::NotStartingWith, MiniDefender::Rules::Numeric, MiniDefender::Rules::Present, MiniDefender::Rules::Prohibited, MiniDefender::Rules::ProhibitedIf, MiniDefender::Rules::ProhibitedUnless, MiniDefender::Rules::Regex, MiniDefender::Rules::Required, MiniDefender::Rules::Size, MiniDefender::Rules::StartingWith, MiniDefender::Rules::String, MiniDefender::Rules::Timezone, MiniDefender::Rules::Unique, MiniDefender::Rules::Url, MiniDefender::Rules::Uuid
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.available? ⇒ Boolean
15
16
17
|
# File 'lib/mini_defender/rule.rb', line 15
def self.available?
true
end
|
10
11
12
|
# File 'lib/mini_defender/rule.rb', line 10
def self.make(args)
self.new
end
|
.signature ⇒ Object
4
5
6
|
# File 'lib/mini_defender/rule.rb', line 4
def self.signature
raise NotImplementedError, 'Use a concrete implementation.'
end
|
Instance Method Details
#active?(validator) ⇒ Boolean
57
58
59
|
# File 'lib/mini_defender/rule.rb', line 57
def active?(validator)
true
end
|
#bails? ⇒ Boolean
Instruct the validator to stop validation for the current attribute when the first error is encountered
46
47
48
|
# File 'lib/mini_defender/rule.rb', line 46
def bails?
false
end
|
#coerce(value) ⇒ Object
67
68
69
|
# File 'lib/mini_defender/rule.rb', line 67
def coerce(value)
value
end
|
#default_value(validator) ⇒ ?Object
40
41
42
|
# File 'lib/mini_defender/rule.rb', line 40
def default_value(validator)
nil
end
|
#defaults?(validator) ⇒ Boolean
34
35
36
|
# File 'lib/mini_defender/rule.rb', line 34
def defaults?(validator)
false
end
|
#error_message(attribute, value, validator) ⇒ Object
99
100
101
|
# File 'lib/mini_defender/rule.rb', line 99
def error_message(attribute, value, validator)
@message || message(attribute, value, validator)
end
|
#excluded?(validator) ⇒ Boolean
63
64
65
|
# File 'lib/mini_defender/rule.rb', line 63
def excluded?(validator)
false
end
|
#force_coerce? ⇒ Boolean
This method is used to change the value regardless if coercion is required
73
74
75
|
# File 'lib/mini_defender/rule.rb', line 73
def force_coerce?
false
end
|
#implicit?(validator) ⇒ Boolean
28
29
30
|
# File 'lib/mini_defender/rule.rb', line 28
def implicit?(validator)
false
end
|
#message(attribute, value, validator) ⇒ Object
87
88
89
|
# File 'lib/mini_defender/rule.rb', line 87
def message(attribute, value, validator)
raise NotImplementedError, 'Use a concrete implementation.'
end
|
#passes?(attribute, value, validator) ⇒ Boolean
80
81
82
|
# File 'lib/mini_defender/rule.rb', line 80
def passes?(attribute, value, validator)
raise NotImplementedError, 'Use a concrete implementation.'
end
|
#priority ⇒ Integer
Priority is used to sort rules in a rule set to allow rules to validate data before rules that will radically change data
22
23
24
|
# File 'lib/mini_defender/rule.rb', line 22
def priority
100
end
|
#stops? ⇒ Boolean
Instructs the validator to stop validation for all rules for the current attribute
51
52
53
|
# File 'lib/mini_defender/rule.rb', line 51
def stops?
false
end
|
#with_message(message) ⇒ Object
91
92
93
94
|
# File 'lib/mini_defender/rule.rb', line 91
def with_message(message)
@message = message
self
end
|