|
|
|
@ -5,6 +5,17 @@ class Projects::CreateForm < BaseForm
|
|
|
|
|
|
|
|
|
|
validates :user_id, :name, :description,:repository_name,
|
|
|
|
|
:project_category_id, :project_language_id, presence: true
|
|
|
|
|
validates_format_of :repository_name, with: REPOSITORY_NAME_REGEX, multiline: true
|
|
|
|
|
# validates_format_of :repository_name, with: REPOSITORY_NAME_REGEX, multiline: true
|
|
|
|
|
validates :repository_name, format: { with: REPOSITORY_NAME_REGEX, multiline: true,
|
|
|
|
|
message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
|
|
|
|
|
|
|
|
|
validate :check_ignore, :check_license
|
|
|
|
|
|
|
|
|
|
def check_license
|
|
|
|
|
raise "license_id值无效. " if license_id && License.find_by(id: license_id).blank?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def check_ignore
|
|
|
|
|
raise "ignore_id值无效." if ignore_id && Ignore.find_by(id: ignore_id).blank?
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|