test_lgq/niucloud/app/validate/member/MemberConfig.php
2024-01-24 17:36:08 +08:00

52 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\validate\member;
use think\facade\Lang;
use think\Validate;
/**
* 会员设置验证
* Class LoginConfig
* @package app\validate\member
*/
class MemberConfig extends Validate
{
protected $rule = [
'length' => 'number|checkLength'
];
protected $message = [
'length.number' => 'validate_member_config.length_number',
];
protected $scene = [
'set' => ['length'],
];
/**
* 自定义验证 长度
* @param $value
* @param $rule
* @param array $data
* @return Lang|true
*/
protected function checkLength($value, $rule, $data = [])
{
$length = (int)$value;
$prefix_len = strlen($data['prefix'] ?? '');
if (empty($length)) return get_lang("validate_member_config.length_number");
if (($length - $prefix_len < 4) || $length > 30) return get_lang("validate_member_config.length_between");
return true;
}
}