添加了对blockchain相关数据格式的检查

This commit is contained in:
zhangxunhui 2023-02-02 21:31:05 +08:00
parent 45cef457d3
commit 8e89be831c
2 changed files with 10 additions and 0 deletions

View File

@ -30,6 +30,14 @@ class BaseForm
raise "项目名称已被使用." if Project.where(user_id: user_id, name: project_name.strip).exists?
end
def check_blockchain_token_all(blockchain_token_all)
raise "请正确填写项目token总数." if (Float(blockchain_token_all) rescue false) == false or blockchain_token_all.to_i < 0 or Float(blockchain_token_all) != blockchain_token_all.to_i
end
def check_blockchain_init_token(blockchain_init_token)
raise "请正确填写项目创始人token占比." if (Float(blockchain_init_token) rescue false) == false or blockchain_init_token.to_i < 0 or blockchain_init_token.to_i > 100 or Float(blockchain_init_token) != blockchain_init_token.to_i
end
def check_reversed_keyword(repository_name)
raise "项目标识已被占用." if ReversedKeyword.check_exists?(repository_name)
end

View File

@ -16,6 +16,8 @@ class Projects::CreateForm < BaseForm
check_project_language(project_language_id)
check_project_name(user_id, name) unless name.blank?
check_repository_name(user_id, repository_name) unless repository_name.blank?
check_blockchain_token_all(blockchain_token_all)
check_blockchain_init_token(blockchain_init_token)
end
def check_license