4 months ago

Is there a way to extend validation rules?

Posted 4 months ago by Chron

I have two create controllers, one for admin and one for customers.

They have similar fields but the customer has extra fields. I'm validating their inputs in one custom request..

    public function rules()
        return [
            'firstname' =>      'required|string|min:2',
            'middlename' =>     'required|regex:/(^([_])$|^([a-zA-Z])+$)/',
            'lastname' =>       'required|string|min:2',

Those are the validation rules for both admin and customers, but like I said, I have extra fields for the customer like 'type' and 'status'.

How can I use the base custom validation and extend it in my CustomerController to create other specific validations?

Please sign in or create an account to participate in this conversation.