__construct()
__construct()
Create a new rule instance.
<?php
/**
* JingYao-backend
*
* @link https://gitee.com/wang-zhihui-release/jingyao-backend
* @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
*/
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class CheckNowAddressRule implements Rule
{
/**
* Create a new rule instance.
*/
public function __construct()
{
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$reg = '/^北京市朝阳区金盏乡东窑村[\d]{1,10}号$/';
if (preg_match($reg, $value)) {
return true;
}
return false;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return '现在住址格式错误, 正确格式为: 北京市朝阳区金盏乡东窑村x号';
}
}