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);
} elseif ($action == "name") {
$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'));

View File

@ -21,7 +21,7 @@ class ValidatorExtendServiceProvider extends ServiceProvider
* @param $v validator
*/
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) {
@ -65,7 +65,7 @@ class ValidatorExtendServiceProvider extends ServiceProvider
protected function registerExpiredRules()
{
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) {

View File

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

View File

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