forgeplus/app/forms/contents/create_form.rb

16 lines
462 B
Ruby

class Contents::CreateForm < BaseForm
attr_accessor :filepath, :branch, :new_branch
validates :filepath, presence: true
validates :new_branch, length: { maximum: 100, too_long: "过长,仅支持%{count}的长度"}
validate :check_branch
def check_branch
raise "branch和new_branch必须存在一个 " if branch.blank? && new_branch.blank?
# raise "branch和new_branch只能存在一个" if !branch.blank? && !new_branch.blank?
end
end