Class: ValidationProfiler::Rules::NotAllowedValidationRule
- Inherits:
-
ValidationRule
- Object
- ValidationRule
- ValidationProfiler::Rules::NotAllowedValidationRule
show all
- Defined in:
- lib/validation_profiler/rules/not_allowed_validation_rule.rb
Instance Method Summary
collapse
#get_field_value, #is_required?
Instance Method Details
#error_message(field, attributes = {}, parent = nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/validation_profiler/rules/not_allowed_validation_rule.rb', line 5
def error_message(field, attributes = {}, parent = nil)
field_name = field.to_s
if parent != nil
field_name = "#{parent.to_s}.#{field.to_s}"
end
if attributes[:message] == nil
"#{field_name} is not allowed."
else
attributes[:message]
end
end
|
#validate(obj, field, attributes = {}, parent = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/validation_profiler/rules/not_allowed_validation_rule.rb', line 22
def validate(obj, field, attributes = {}, parent = nil)
field_value = get_field_value(obj, field)
if field_value != nil
return false
end
return true
end
|