Files
portal-api/app/Http/Requests/Api/BillingProfileRequest.php

33 lines
943 B
PHP

<?php
namespace App\Http\Requests\Api;
use Illuminate\Foundation\Http\FormRequest;
class BillingProfileRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'invoice_company' => 'nullable|string|max:255|required_with:tax_code',
'tax_code' => ['nullable', 'string', 'regex:/^\d{10}(-\d{3})?$/'],
'invoice_address' => 'nullable|string|max:500',
'invoice_email' => 'nullable|email|max:255',
];
}
public function messages(): array
{
return [
'tax_code.regex' => 'Mã số thuế phải gồm 10 số hoặc 13 số (dạng 0123456789-001)',
'invoice_company.required_with' => 'Vui lòng nhập tên đơn vị khi có mã số thuế',
'invoice_email.email' => 'Email nhận hóa đơn không hợp lệ',
];
}
}