Class: RequiredValidationRule
Instance Method Summary
collapse
#get_field_value, #is_required?
Instance Method Details
#error_message(field, attributes = {}) ⇒ Object
214
215
216
217
218
219
220
221
222
|
# File 'lib/validation_profiler/rules/rules.rb', line 214
def error_message(field, attributes = {})
if attributes[:message] == nil
"#{field} is required"
else
attributes[:message]
end
end
|
#validate(obj, field, attributes = {}) ⇒ Object
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/validation_profiler/rules/rules.rb', line 225
def validate(obj, field, attributes = {})
field_value = get_field_value(obj, field)
if field_value == nil
return false
end
return !field_value.empty?
end
|