Using Spatie/Laravel-Data to validate Filament Forms

Is it possible to take advantage of Laravel Data to validate Filament forms?
Some projects require using Laravel Data for proper validation in different contexts (API, commands, jobs, etc), and it becomes redundant to duplicate validation rules in Filament forms for every resource. I'm looking for a way to integrate both effectively. Here's my current approach:
$rules = StockMovementData::getValidationRules([]);
return [
TextInput::make('quantity')
->rules($rules['quantity'])
->numeric()
// ....
];
$rules = StockMovementData::getValidationRules([]);
return [
TextInput::make('quantity')
->rules($rules['quantity'])
->numeric()
// ....
];
While this basic implementation works for validation rules, it doesn't leverage other Laravel Data features like: - Custom validation messages - Type casting - Complex validations - Data Object reusability Has anyone found a more elegant solution to integrate these tools? Any advice or examples would be greatly appreciated!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server