This package provides a flexible date rule builder for Laravel Filament applications. It allows you to create complex date validation rules through a user-friendly interface.
Key features:
- Build compound date rules using logical operators (AND/OR)
- Multiple rule types available:
- Date ranges
- Specific dates
- Days of week
- Holidays
- Weekly patterns
- Exceptions
- Leap days
- Conditional rules
- Fully integrated with Filament forms
- Rules are serializable to JSON for storage
- Easy to extend with custom rule types
The date rule builder can be used to create sophisticated date validation logic, such as:
- Business hours and holiday schedules
- Event availability patterns
- Date-based access control
- Custom calendar rules
Each rule implements a passes() method that checks if a given date matches the rule's criteria. Rules can be combined using AND/OR operators and can include exceptions. The builder component provides an intuitive interface for constructing these rule sets within your Filament forms.
You can install the package via composer:
composer require apility/filament-daterules** TODO **
You can extend the date rule system with your own custom rules. To create a custom rule:
- Create a class that implements the
Apility\DateRules\Contracts\DateRuleinterface, implement the following methodspasses(CarbonImmutable $date): bool- Determines if the date matches the rulebounds(): ?CarbonPeriodImmutable- Optional method to specify date bounds
- If you want to use this custom rule in Filament, we recommend extending from the abstract
Apility\DateRules\Rules\Ruleclass, and implement the following methodblock(): Block- Defines the Filament form fields for configuring the rule
- Anywhere you want to include this custom rule, define what rules the DateRules component should includes (example below)
use Apility\DateRules\Filament\Forms\Components\DateRules;
...
DateRules::make('my-date-rules')
->Here's an example of a custom rule for checking if a date is July 4th:
<?phpPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.