fix some validate problem

This commit is contained in:
LI JIAHAO
2017-05-26 21:02:53 +08:00
parent f1a77019c2
commit 2e7eae57b8
8 changed files with 29 additions and 12 deletions
+4 -2
View File
@@ -26,8 +26,8 @@ class addGoodRequest extends Request
return [
'good_name'=>'required|max:128',
'description'=>'max:2048',
'price'=>'required|max:9223372036854775807',
'count'=>'required|max:2147483647',
'price'=>'numeric|required|max:9223372036854775807',
'count'=>'integer|required|max:2147483647',
//'good_tag'=>'required',
//'other_tag'=>'max:128',
'goodTitlePic'=>'required',
@@ -44,8 +44,10 @@ class addGoodRequest extends Request
'good_name.max' => '商品名不能多于128个字符!',
'description.max' => '商品描述不能多于2048个字符!',
'price.required' => '商品价格不能为空!',
'price.numeric' => '商品价格必须为数值!',
'price.max' => '商品价格不能超过9223372036854775807!',
'count.required' => '库存数不能为空!',
'count.integer' => '库存数必须是整数!',
'count.max' => '库存数不能超过2147483647!',
//'good_tag.required' => '商品标签不能为空!',
//'other_tag.max' => '自定义标签不能多于2048个字符!',
+4 -2
View File
@@ -26,8 +26,8 @@ class EditGoodRequest extends Request
return [
'good_name'=>'required|max:128',
'description'=>'max:2048',
'price'=>'required|max:9223372036854775807',
'count'=>'required|max:2147483647',
'price'=>'numeric|required|max:9223372036854775807',
'count'=>'integer|required|max:2147483647',
//'good_tag'=>'required',
//'other_tag'=>'max:128',
];
@@ -39,6 +39,8 @@ class EditGoodRequest extends Request
'good_name.between' => '商品名不能多于128个字符!',
'description.max' => '商品描述不能多于2048个字符!',
'price.required' => '商品价格不能为空!',
'price.numeric' => '商品价格必须为数值!',
'count.integer' => '库存数必须是整数!',
'price.max' => '商品价格不能超过9223372036854775807!',
'count.required' => '库存数不能为空!',
'count.max' => '库存数不能超过2147483647!',
+2 -2
View File
@@ -26,7 +26,7 @@ class SendMessageRequest extends FormRequest
return [
'title'=>'required|max:128',
'content'=>'max:65535',
'receiver'=>'required|numeric',
'receiver'=>'required|integer',
];
}
@@ -36,7 +36,7 @@ class SendMessageRequest extends FormRequest
'title.max' => '标题长度不能超过128个字符!',
'content.max' => '内容长度不能超过65535个字符',
'receiver.required' => '收件人不可为空',
'receiver.numeric' => '收件人格式不正确!'
'receiver.integer' => '收件人格式不正确!'
];
}
}
@@ -17,7 +17,7 @@ class CreateGoodInfoTable extends Migration
$table->string('good_name');
$table->integer('cat_id');
$table->text('description');
$table->bigInteger('price');
$table->double('price');
$table->tinyInteger('type');
$table->integer('user_id');
$table->integer('count');
+1 -1
View File
@@ -53,7 +53,7 @@
<label class="right inline">商品价格:</label>
</div>
<div class="small-10 columns">
<input type="number" name="price" value="{{old('price')}}" placeholder="商品价格">
<input type="text" name="price" value="{{old('price')}}" placeholder="商品价格">
</div>
</div>
<div class="row">
+1 -1
View File
@@ -62,7 +62,7 @@
<label class="right inline">商品价格:</label>
</div>
<div class="small-10 columns">
<input type="number" name="price" value="{{count($errors) ? old('price') : $good->price}}" placeholder="商品价格">
<input type="text" name="price" value="{{count($errors) ? old('price') : $good->price}}" placeholder="商品价格">
</div>
</div>
<div class="row">
+15 -2
View File
@@ -26,10 +26,16 @@ class GoodTest extends BrowserKitTestCase
->type('刘汝佳', 'description')
->press('添加')
->see('商品价格不能为空')
->type('65', 'price')
->type('aaa', 'price')
->press('添加')
->see('商品价格必须为数值')
->type('65.5', 'price')
->press('添加')
->see('库存数不能为空')
->select('1', 'type')
->type('10.5', 'count')
->press('添加')
->see('库存数必须是整数')
->type('10', 'count')
->press('添加')
->see('必须为商品上传一张图片')
@@ -42,7 +48,7 @@ class GoodTest extends BrowserKitTestCase
->type('50', 'crop_x')
->type('137.5', 'crop_y')
->press('添加')
->see('修改');
->see('65.5');
}
public function testGoodPic()
@@ -135,10 +141,17 @@ class GoodTest extends BrowserKitTestCase
->type('', 'price')
->press('更改')
->see('商品价格不能为空')
->type('aaa', 'price')
->press('更改')
->see('商品价格必须为数值')
->type('2333', 'price')
->type('', 'count')
->press('更改')
->see('库存数不能为空')
->type('10.5', 'count')
->press('更改')
->see('库存数必须是整数')
->type('10', 'count')
->type('汝佳大法好', 'description')
->type('666', 'price')
->type('10', 'count')
+1 -1
View File
@@ -22,7 +22,7 @@ class MessageTest extends BrowserKitTestCase
->seeStatusCode(302)
->post('message', ['title' => 'testMessage'])
->seeStatusCode(302)
->post('message', ['title' => 'testMessage', 'receiver' => 'aaa'])
->post('message', ['title' => 'testMessage', 'receiver' => '10.5'])
->seeStatusCode(302)
->post('message', ['title' => 'testMessage', 'receiver' => '1024'])
->seeJson(['result' => false, 'msg' => 'no such receiver'])