rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.76k stars 330 forks source link

Allow Disabling Filter Validation & Custom Validation #1594

Closed lrljoe closed 7 months ago

lrljoe commented 9 months ago

TESTS TO FOLLOW SHORTLY

The filters have built-in validation, and return types defined within the built-in validation methods to ensure that the data type is returned is functional.

This PR allows for: 1) Disabling the internal validation 2) Use of a Call-back to use custom validation rules, either in conjunction with internal rules, or replacing them

Disabling Validation

To disable default validation on a Filter, you may call:

    TextFilter::make('Success No')
    ->setValidationDisabled(),

Custom Validation Callback

You can also use a custom validation method, in which case you may use the "validation()" method on the Filter to define a custom validation callback.

You may choose to either supplement, or override the default validation methods. To override the internal validation, Disable Validation on the filter. To supplement the internal validation, Enable Validation (enabled by default). Note that the internal validation will run first.

    TextFilter::make('Success No')
    ->validation(function ($value) { return $value == 'test' ? $value : false;}),

All Submissions:

New Feature Submissions:

  1. [ ] Does your submission pass tests and did you add any new tests needed for your feature?
  2. [X] Did you update all templates (if applicable)?
  3. [X] Did you add the relevant documentation (if applicable)?
  4. [X] Did you test locally to make sure your feature works as intended?

Changes to Core Features:

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.