New-Thanasoft/thanasoft-back/app/Http/Requests/StoreFournisseurRequest.php
2025-10-28 18:03:44 +03:00

60 lines
2.4 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreFournisseurRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'vat_number' => 'nullable|string|max:32',
'siret' => 'nullable|string|max:20',
'email' => 'nullable|email|max:191',
'phone' => 'nullable|string|max:50',
'billing_address_line1' => 'nullable|string|max:255',
'billing_address_line2' => 'nullable|string|max:255',
'billing_postal_code' => 'nullable|string|max:20',
'billing_city' => 'nullable|string|max:191',
'billing_country_code' => 'nullable|string|size:2',
'notes' => 'nullable|string',
'is_active' => 'boolean',
];
}
public function messages(): array
{
return [
'name.required' => 'Le nom du fournisseur est obligatoire.',
'name.string' => 'Le nom du fournisseur doit être une chaîne de caractères.',
'name.max' => 'Le nom du fournisseur ne peut pas dépasser 255 caractères.',
'vat_number.max' => 'Le numéro de TVA ne peut pas dépasser 32 caractères.',
'siret.max' => 'Le SIRET ne peut pas dépasser 20 caractères.',
'email.email' => 'L\'adresse email doit être valide.',
'email.max' => 'L\'adresse email ne peut pas dépasser 191 caractères.',
'phone.max' => 'Le téléphone ne peut pas dépasser 50 caractères.',
'billing_address_line1.max' => 'L\'adresse ne peut pas dépasser 255 caractères.',
'billing_address_line2.max' => 'Le complément d\'adresse ne peut pas dépasser 255 caractères.',
'billing_postal_code.max' => 'Le code postal ne peut pas dépasser 20 caractères.',
'billing_city.max' => 'La ville ne peut pas dépasser 191 caractères.',
'billing_country_code.size' => 'Le code pays doit contenir 2 caractères.',
'is_active.boolean' => 'Le statut actif doit être vrai ou faux.',
];
}
}