My Validation class looks like this
<?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'
);
}
}
I want to validate recieved_amount
as Money field Like if anything other than money is entered it should be validated
Can any one help me in this
You can use this, for example (being 'amount' the money quantity):
public static $rules = array(
'amount' => "required|regex:/^\d+(\.\d{1,2})?$/"
));
The regex will hold for quantities like '12' or '12.5' or '12.05'. If you want more decimal points than two, replace the "2" with the allowed decimals you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With