nodonhq / filament-argentina
Argentine form fields, table columns and validation rules for Filament: CUIT/CUIL, DNI, CBU/CVU, alias, phone, provinces, pesos and IVA condition.
Requires
- php: ^8.3
- filament/forms: ^5.0
- filament/infolists: ^5.0
- filament/tables: ^5.0
- illuminate/contracts: ^12.0|^13.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.20
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^11.5|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Form fields, table columns, infolist entries and validation rules for the data every Argentine app asks for: CUIT/CUIL, DNI, CBU/CVU, alias, phone numbers, amounts in pesos, provinces and VAT condition.
- Real validation: CUIT and CBU check digits, not just a regex.
- Typing masks (
20-12345678-6,12.345.678,$ 1.234,56). - Stores clean values (only digits, plain decimals) and shows them formatted.
- The validation rules also work in plain Laravel, without Filament.
- Messages in Spanish and English.
Requires PHP 8.3+ and Filament 5.
Installation
composer require nodonhq/filament-argentina
Form fields
use NodonHq\FilamentArgentina\Forms\CbuAliasInput; use NodonHq\FilamentArgentina\Forms\CbuInput; use NodonHq\FilamentArgentina\Forms\CuitInput; use NodonHq\FilamentArgentina\Forms\DniInput; use NodonHq\FilamentArgentina\Forms\PesosInput; use NodonHq\FilamentArgentina\Forms\PhoneInput; use NodonHq\FilamentArgentina\Forms\ProvinceSelect; use NodonHq\FilamentArgentina\Forms\TaxConditionSelect; CuitInput::make('cuit')->label('CUIT'), // stores 20123456786 CuitInput::make('cuit')->company(), // only legal entities (30, 33, 34) CuitInput::make('cuil')->person(), // only individuals DniInput::make('dni'), // stores 12345678 CbuInput::make('cbu'), // CBU or CVU, stores the 22 digits CbuInput::make('cvu')->cvuOnly(), // or ->cbuOnly() CbuAliasInput::make('alias'), PhoneInput::make('phone'), // stores 1123456789 PhoneInput::make('whatsapp')->e164(mobile: true), // stores +5491123456789 PesosInput::make('price'), // typed 1.234,56, stores "1234.56" ProvinceSelect::make('province'), // stores the ISO 3166-2 code (AR-X) TaxConditionSelect::make('tax_condition'), // stores ARCA's id (5 = Consumidor Final)
To keep the separators in the database, add ->storeFormatted() to the CUIT, DNI or CBU fields.
| Field | Mask / input | Stored value | Validation |
|---|---|---|---|
CuitInput |
99-99999999-9 |
20123456786 |
prefix and modulo 11 check digit |
DniInput |
9.999.999 / 99.999.999 |
12345678 |
7 or 8 digits |
CbuInput |
99999999 99999999999999 |
22 digits | both check digits; CBU, CVU or either |
CbuAliasInput |
max. 20 chars | as typed | 6–20 letters, digits, . or - |
PhoneInput |
+54 prefix |
10 national digits or E.164 | area code + number |
PesosInput |
$ 1.234,56 |
"1234.56" |
amount |
ProvinceSelect |
24 jurisdictions | AR-C, AR-B, ... |
enum |
TaxConditionSelect |
ARCA list | 1, 4, 5, 6, ... |
enum |
Table columns and infolist entries
use NodonHq\FilamentArgentina\Tables\CbuColumn; use NodonHq\FilamentArgentina\Tables\CuitColumn; use NodonHq\FilamentArgentina\Tables\DniColumn; use NodonHq\FilamentArgentina\Tables\PesosColumn; CuitColumn::make('cuit'), // 20-12345678-6 DniColumn::make('dni'), // 12.345.678 CbuColumn::make('cbu'), // 01105995 40000000123457 PesosColumn::make('price'), // $ 1.234,56 (right aligned)
The same exist for infolists in NodonHq\FilamentArgentina\Infolists: CuitEntry, DniEntry, CbuEntry and PesosEntry.
For provinces and VAT condition, cast the attribute to the enum and use a regular TextColumn: it shows the label.
protected function casts(): array { return [ 'province' => \NodonHq\FilamentArgentina\Enums\Province::class, 'tax_condition' => \NodonHq\FilamentArgentina\Enums\TaxCondition::class, ]; }
Validation rules (Laravel, no Filament needed)
use NodonHq\FilamentArgentina\Rules\ArgentinePhone; use NodonHq\FilamentArgentina\Rules\Cbu; use NodonHq\FilamentArgentina\Rules\CbuAlias; use NodonHq\FilamentArgentina\Rules\Cuit; use NodonHq\FilamentArgentina\Rules\Dni; use NodonHq\FilamentArgentina\Rules\PesosAmount; $request->validate([ 'cuit' => ['required', new Cuit], 'company_cuit' => ['required', Cuit::make()->company()], 'dni' => [new Dni], 'cbu' => [new Cbu], 'cvu' => [Cbu::make()->cvuOnly()], 'alias' => [new CbuAlias], 'phone' => [new ArgentinePhone], 'amount' => [new PesosAmount], ]);
The checks behind them are available as plain helpers in NodonHq\FilamentArgentina\Support (Cuit::isValid(), Cuit::format(), Cbu::isCvu(), Phone::e164(), Pesos::parse(), ...).
Translations
Messages come in Spanish (es) and English (en) and follow the app locale. To change them:
php artisan vendor:publish --tag=filament-argentina-translations
Notes and limits
- Phone numbers must include the area code. The old mobile format with
15(011 15 1234-5678) is not accepted: use11 1234-5678or+54 9 11 1234-5678. - The CUIT check is offline: it verifies the number is well formed, not that it is registered with ARCA.
- CUIT prefixes accepted by default: 20, 23, 24, 25, 26, 27 (individuals) and 30, 33, 34 (legal entities).
Testing
composer test
composer analyse
License
MIT. See LICENSE.md.
