- How do I install and use this package in a Laravel project?
- Run `composer require czechphp/czech-bank-account` to install. Register the validator in `AppServiceProvider` as a singleton, then inject or facade it into your services. Example: `BankAccount::validate('CZ12345678900000000000')` for IBAN validation.
- Does this package support both IBAN and Czech domestic account formats?
- Yes, it validates both IBAN (e.g., `CZ12345678900000000000`) and domestic formats (e.g., `1234567890/0100`). Use the `BankAccountNumberValidator` for general checks or specialized validators like `BankCodeValidator` for bank-specific codes.
- What Laravel versions and PHP requirements does this package support?
- The package requires PHP 8.1+, which aligns with Laravel 9+. For Laravel 8.x, ensure PHP 8.1 compatibility is met. Test thoroughly if using older versions, as some features may rely on newer PHP syntax.
- How can I validate variable symbols (e.g., for bank transfers)?
- Use the `VariableSymbolValidator` class. Example: `$validator = new VariableSymbolValidator(); $validator->validate('123')` returns `ERROR_NONE` if valid. For constant symbols, use `ConstantSymbolValidator` with formats like `0006`.
- Is there a way to load bank codes dynamically (e.g., from a database)?
- The package uses a `LoaderInterface` for bank codes. Implement your own loader (e.g., `DatabaseLoader`) to fetch codes from a database instead of the default filesystem loader. Extend `FilesystemLoader` as a reference.
- How should I handle validation errors in Laravel?
- The package throws exceptions for invalid formats (e.g., `InvalidArgumentException`). Use Laravel’s exception handler to format errors consistently. Log violations for auditing or return user-friendly messages in APIs.
- Can this package validate non-Czech accounts (e.g., EU IBANs)?
- No, this package is optimized for Czech-specific validation (CNB rules). For EU-wide IBAN validation, consider `league/iban` alongside this package. Combine them in a service layer for broader coverage.
- What’s the performance impact of validating 10,000+ accounts per minute?
- The package is lightweight and stateless, making it suitable for high-throughput systems. Benchmark in your environment, but expect sub-millisecond latency for most validations. Cache results if repeated checks occur.
- How do I test this package in Laravel unit tests?
- Mock the validator in tests (e.g., `BankAccountNumberValidator::validate()`). Test edge cases like malformed inputs (`CZ123`), empty strings, and valid/invalid Czech accounts. Use Laravel’s `partialMock` for partial mocking if needed.
- What if CNB changes validation rules in the future? Will this package break?
- Monitor the package’s GitHub for updates. If rules change, the maintainers may release a patch. As a fallback, implement a secondary validation layer (e.g., CNB’s API) or fork the package for custom rules.