class RediSearch::Validations::Presence
Attributes
field[R]
Public Class Methods
new(field:)
click to toggle source
# File lib/redi_search/validations/presence.rb, line 6 def initialize(field:) @field = field end
Public Instance Methods
validate!(object)
click to toggle source
# File lib/redi_search/validations/presence.rb, line 10 def validate!(object) return true if value_present?(object.send(field)) raise RediSearch::ValidationError, "#{field} can't be blank" end
Private Instance Methods
value_present?(value)
click to toggle source
# File lib/redi_search/validations/presence.rb, line 20 def value_present?(value) if value.respond_to?(:empty?) !value.empty? else value end end