联系人提示
This commit is contained in:
@@ -6,6 +6,25 @@ use think\Validate;
|
||||
|
||||
class ContactsValidator extends Validate
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// 初始化验证消息
|
||||
$this->message = [
|
||||
'name.require' => trans('name_not_null'),
|
||||
'name.max' => trans('name_max'),
|
||||
'name.checkEmptyString' => trans('name_check_empty'),
|
||||
'phone.require' => trans('phone_not_null'),
|
||||
'phone.checkInternationalPhone' => trans('phone_international'),
|
||||
'content.require' => trans('content_not_null'),
|
||||
'content.min' => trans('content_min'),
|
||||
'content.max' => trans('content_max'),
|
||||
'vehicle_id.integer' => trans('vehicle_id_integer'),
|
||||
'email.email' => trans('email'),
|
||||
];
|
||||
}
|
||||
|
||||
// 验证规则
|
||||
protected $rule = [
|
||||
'name' => 'require|max:255|checkEmptyString',
|
||||
@@ -16,18 +35,7 @@ class ContactsValidator extends Validate
|
||||
];
|
||||
|
||||
// 错误提示信息
|
||||
protected $message = [
|
||||
'name.require' => '姓名不能为空',
|
||||
'name.max' => '姓名长度不能超过255个字符',
|
||||
'name.checkEmptyString' => '姓名不能只包含空格',
|
||||
'phone.require' => '联系电话不能为空',
|
||||
'phone.checkInternationalPhone' => '请使用国际格式',
|
||||
'content.require' => '内容不能为空',
|
||||
'content.min' => '内容至少需要10个字符',
|
||||
'content.max' => '内容长度超过最大限制',
|
||||
'vehicle_id.integer' => '车辆ID必须为数字',
|
||||
'email.email' => '邮箱格式不正确'
|
||||
];
|
||||
protected $message = [];
|
||||
|
||||
// 验证场景
|
||||
protected $scene = [
|
||||
|
||||
Reference in New Issue
Block a user