add: organization validate
This commit is contained in:
parent
604c2595d3
commit
d867823f01
|
@ -36,6 +36,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
Organizations::CreateForm.new(organization_params).validate!
|
||||
login = @organization.login
|
||||
@organization.login = organization_params[:name] if organization_params[:name].present?
|
||||
@organization.nickname = organization_params[:nickname] if organization_params[:nickname].present?
|
||||
|
|
|
@ -3,6 +3,9 @@ class Organizations::CreateForm < BaseForm
|
|||
attr_accessor :name, :description, :website, :location, :repo_admin_change_team_access, :visibility, :max_repo_creation, :nickname
|
||||
|
||||
validates :name, :nickname, :visibility, presence: true
|
||||
validates :name, :nickname, length: { maximum: 100 }
|
||||
validates :location, length: { maximum: 50 }
|
||||
validates :description, length: { maximum: 200 }
|
||||
validates :name, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
'zh-CN':
|
||||
activemodel:
|
||||
attributes:
|
||||
organizations/create_form:
|
||||
name: 组织账号
|
||||
nickname: 组织名称
|
||||
location: 组织所在地区
|
||||
description: 组织简介
|
||||
visibility: 组织可见性
|
Loading…
Reference in New Issue