I am developing in Laravel 5.1 and I am having a small problem when validating a form, I am using Request for this, the rules I have are the following:
ProductoCreateRequest
public function rules()
{
return ['nombre' => 'required|max:50',
'presentacion' => 'required',
'unidad' => 'required',
'codigo' => 'required|numeric|max:4',
'almacen' => 'required',
'categoria' => 'required',
'pathImg' => 'image',
];
}
The problem here is that the image is taking it as it is required, what I'm looking for is that it only validates when a file was uploaded, if nothing is uploaded then it does not mark the error that it needs to be a image, as well as in code , my validation is that it is maximum of 4 digits, but it always marks me error when I write less of these, it only allows me 1 digit, when writing 2 or 3 it marks me that error.
I would appreciate your help.