本地生活商品添加验证规则
This commit is contained in:
parent
33bf92de0f
commit
809fd2a091
@ -14,7 +14,7 @@ class LocalStoreGoodsValidate extends Validate
|
||||
'lstore_id' => 'require',
|
||||
'title' => 'require',
|
||||
'price' => 'require|checkPrice',
|
||||
'url' => 'require'
|
||||
'url' => 'require|checkPic'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
@ -24,7 +24,8 @@ class LocalStoreGoodsValidate extends Validate
|
||||
'url.require' => '商品图片不能为空',
|
||||
];
|
||||
|
||||
public function checkPrice($value, $data, $rule)
|
||||
// 检查金额格式
|
||||
public function checkPrice($value)
|
||||
{
|
||||
$pattern = '/^\d+(\.\d{1,2})?$/';
|
||||
if (!preg_match($pattern, $value)) {
|
||||
@ -32,4 +33,10 @@ class LocalStoreGoodsValidate extends Validate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查商品图片
|
||||
public function checkPic($value)
|
||||
{
|
||||
dump($value);die;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user