Download the PHP package alihaider/flexible-boolean without Composer
On this page you can find all versions of the php package alihaider/flexible-boolean. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alihaider/flexible-boolean
More information about alihaider/flexible-boolean
Files in alihaider/flexible-boolean
Package flexible-boolean
Short Description Flexible boolean validation rule supporting true/false strings and values
License MIT
Informations about the package flexible-boolean
Flexible Boolean for Laravel
A powerful and flexible boolean validation rule for Laravel that supports real-world API and frontend inputs like "true" and "false".
๐ Why This Package Exists
Laravel's default boolean validation rule does NOT accept string values like:
"true""false"
However, in real-world applications (APIs, frontend forms, third-party integrations), boolean values are often sent as strings.
This package solves that problem by providing a flexible and reliable boolean validation rule.
โจ Features
- Supports:
true/false"true"/"false"1/0"1"/"0"
- Laravel validation rule
- Helper methods for conversion
- Fully testable and production ready
๐ฆ Installation
Install via Composer:
โ๏ธ Service Provider
Laravel supports auto-discovery, so no manual registration is required.
If you are using an older Laravel version or need to register manually, add the service provider:
// config/app.php
โ Usage
1. Validation Rule
2. Using Rule Class
3. Convert Value to Boolean
โ๏ธ Comparison with Laravel Default
| Feature | Laravel Default | This Package |
|---|---|---|
Accept "true" string |
โ No | โ Yes |
Accept "false" string |
โ No | โ Yes |
| Strict boolean validation | โ Yes | โ Yes |
| API-friendly | โ Limited | โ Fully |
๐งช Example (Real-World API)
Validation:
All versions of flexible-boolean with dependencies
illuminate/support Version ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0