Skip to content

owowagency/remove-required-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Remove required rules

Latest Version on Packagist Total Downloads GitHub Actions

Sometimes you'd like to reuse all rules from the store request in an update request, but without the required rules. This helper methods does that for you. It loops through all the rules and tries to remove the required rule for you.

Installation

You can install the package via composer:

composer require owowagency/remove-required-rules

Usage

$rules = remove_required($rules);

What this would look like in a form request

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        // Input: 'required|string' or ['required', 'string']
        $rules = (new StoreRequest())->rules();

        // Output: 'string' or ['string']
        return remove_required($rules);
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Remove Required Rules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages