Fix form validation rules

This commit is contained in:
printempw 2018-08-15 13:57:20 +08:00 committed by Pig Fang
parent aff8e9f058
commit 23b2abdfaf
4 changed files with 23 additions and 37 deletions

View File

@ -468,7 +468,7 @@ class AdminController extends Controller
return json(trans('admin.players.delete.success'), 0); return json(trans('admin.players.delete.success'), 0);
} elseif ($action == "name") { } elseif ($action == "name") {
$this->validate($request, [ $this->validate($request, [
'name' => 'required' 'name' => 'required|player_name|min:'.option('player_name_length_min').'|max:'.option('player_name_length_max')
]); ]);
$player->rename($request->input('name')); $player->rename($request->input('name'));

View File

@ -21,7 +21,7 @@ class ValidatorExtendServiceProvider extends ServiceProvider
* @param $v validator * @param $v validator
*/ */
Validator::extend('no_special_chars', function ($a, $value, $p, $v) { Validator::extend('no_special_chars', function ($a, $value, $p, $v) {
return $value === addslashes(trim($value)); return $value === e(addslashes(trim($value)));
}); });
Validator::extend('player_name', function ($a, $value, $p, $v) { Validator::extend('player_name', function ($a, $value, $p, $v) {
@ -65,7 +65,7 @@ class ValidatorExtendServiceProvider extends ServiceProvider
protected function registerExpiredRules() protected function registerExpiredRules()
{ {
Validator::extend('nickname', function ($a, $value, $p, $v) { Validator::extend('nickname', function ($a, $value, $p, $v) {
return $value === addslashes(trim($value)); return $value === e(addslashes(trim($value)));
}); });
Validator::extend('playername', function($a, $value, $p, $v) { Validator::extend('playername', function($a, $value, $p, $v) {

View File

@ -76,8 +76,10 @@ url: 'The :attribute format is invalid.'
# Here you may specify custom validation messages for attributes using the # Here you may specify custom validation messages for attributes using the
# convention "attribute.rule" to name the lines. This makes it quick to # convention "attribute.rule" to name the lines. This makes it quick to
# specify a specific custom language line for a given attribute rule. # specify a specific custom language line for a given attribute rule.
#
custom: custom:
attribute-name: { rule-name: custom-message } attribute-name:
rule-name: custom-message
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Custom Validation Attributes # Custom Validation Attributes

View File

@ -1,7 +1,7 @@
# Blessing Skin # Blessing Skin
username: ':attribute 格式错误。' username: ':attribute 格式错误。'
player_name: ':attribute 不符合规则。' player_name: ':attribute 不符合规则。'
no_special_chars: ':attribute 不能包含特殊字。' no_special_chars: ':attribute 不能包含特殊字。'
preference: ':attribute 的值必须为 default 或 slim。' preference: ':attribute 的值必须为 default 或 slim。'
model: ':attribute 的值必须为 steve、alex 或 cape。' model: ':attribute 的值必须为 steve、alex 或 cape。'
@ -73,43 +73,27 @@ unique: ':attribute 已经存在。'
url: ':attribute 格式不正确。' url: ':attribute 格式不正确。'
custom: custom:
attribute-name: { rule-name: custom-message } attribute-name:
rule-name: custom-message
identification: identification:
required: 邮箱或角色名格式错误 required: 邮箱或角色名格式错误
attributes: attributes:
name: 名称 email: 邮箱
file: 文件 new_email: 新邮箱
username: 用户名 username: 用户名
identification: 邮箱或角色名 identification: 邮箱或角色名
new_player_name: 角色名
sitename: 站点名称
nickname: 昵称
player_name: 角色名
email: 邮箱
first_name:
last_name:
password: 密码 password: 密码
password_confirmation: 确认密码 password_confirmation: 确认密码
city: 城市 nickname: 昵称
country: 国家 new_nickname: 新昵称
address: 地址 player_name: 角色名
phone: 电话 new_player_name: 新角色名
mobile: 手机 preference: 优先模型
age: 年龄 model: 模型
sex: 性别 name: 名称
gender: 性别 new_name: 新名称
day: score: 积分
month: file: 文件
year: public: 是否公开
hour: site_name: 站点名称
minute:
second:
title: 标题
content: 内容
description: 描述
excerpt: 摘要
date: 日期
time: 时间
available: 可用的
size: 大小