我的验证类看起来像这样
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class PaymentRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = array(
'invoiceid'=>'required',
'recieved_amount'=>'required',
'ref_no'=>'required',
'date'=>'required',
'comment'=>'required'
);
}
}
我想验证recieved_amount
为Money字段如果输入了除money以外的任何东西,则应该验证它
任何人都可以帮助我
例如,你可以使用它(作为'金额'的金额):
public static $rules = array(
'amount' => "required|regex:/^\d+(\.\d{1,2})?$/"
));
正则表达式将保留数量为“12”或“12 .5”或“12 .05”。如果您想要更多的小数点,请将“2”替换为您需要的允许小数。