You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
729 B
23 lines
729 B
class Ecs::SaveCourseEvaluationForm
|
|
include ActiveModel::Model
|
|
|
|
attr_accessor :name, :evaluation_count, :status, :course_evaluation_subitems
|
|
|
|
validates :name, presence: true
|
|
validates :evaluation_count, presence: true, numericality: { only_integer: true }
|
|
validates :status, presence: true, inclusion: { in: %w[partly totality] }
|
|
|
|
validate :course_evaluation_subitems_validate
|
|
def course_evaluation_subitems_validate
|
|
if course_evaluation_subitems.blank?
|
|
errors.add(:course_evaluation_subitems, :blank)
|
|
return
|
|
end
|
|
|
|
if course_evaluation_subitems.any? { |item| item[:name].blank? }
|
|
errors.add(:course_evaluation_subitems, :name_blank)
|
|
return
|
|
end
|
|
end
|
|
end
|