nanopkg/laravel-bd-phone-verification-rule
Rule class, making it non-intrusive and composable with existing validation logic.Rule interface, ensuring consistency with other validation rules (e.g., email, numeric). This reduces cognitive load for developers familiar with Laravel’s ecosystem.bdPhone rule in validation arrays require <5 lines of code for basic usage.laravel/framework constraints in composer.json). If using Laravel 10+, backward compatibility may need verification (e.g., Rule class changes).+880, 01XX, 8801XX)?messages() in FormRequest)?Illuminate\Validation\Rules\Phone (Laravel 10+) suffice with less risk?FormRequest or JSON payloads.egulias/email-validator or giggsey/libphonenumber-for-php instead).+8801234567890, 0123456789, 880-1234567890).FormRequest, API resources).bdPhone rule in FormRequest classes or controller validation arrays.resources/lang if customization is needed.spatie/laravel-validation-rules).Rule::make() vs. custom Rule classes).string length).composer.json and publish the rule via php artisan vendor:publish (if extending).composer update, but manual testing is recommended due to stale maintenance.BdPhoneRule class).class PhoneValidator extends BdPhoneRule {
public function passes($attribute, $value) {
// Custom logic
return parent::passes($attribute, $value);
}
}
$validator = Validator::make($data, ['phone' => 'bdPhone']);
if ($validator->fails()) {
\Log::error('BD Phone Validation Failed', ['errors' => $validator->errors()]);
}
Validator::extend().| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid BD number slips through | User data corruption | Add manual review for edge cases. |
| Package breaks with Laravel 10+ | Validation failures | Fork and maintain locally. |
| False positives (e.g., non-BD nums) | User frustration | Combine with starts_with:880 rule. |
| No updates for new BD prefixes | Rule becomes obsolete | Monitor BD telecom regulations. |
bdPhone|required).+8801234567890, 01712345678).abc, +9991234567890).How can I help you explore Laravel packages today?