Is there a way where I can have a form validation rule in laravel 5, where the field must be min:6 or zero?
Regards, Andreas
I have no idea why a field should be a minimum of zero, but I guess you mean the field should be optional(not required). Here goes a Sample Request class you could use:
<?php namespace CRM\Http\Requests;
use CRM\Http\Requests\Request;
class PostRequest 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()
{
return [ 'title'=> 'sometimes|required|min:6' ];
}
}
I hope that helps.