0

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

sometimes was what I looked for:-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.