Rails valida se presente

validates_format_of :avatar_file_name, 
 :with=>/\.(jpeg|jpg|png|gif)$/i, 
 :message=> I18n.t("..."), 
 :on => :update,
 :if => lambda{ |object| object.avatar_file_name.present? }
TalaatMagdy