|
|
@@ -15,10 +15,11 @@ class ClientPaymentMethodRequest extends FormRequest
|
|
|
{
|
|
|
$rules = [
|
|
|
'client_id' => ['sometimes', 'integer', 'exists:clients,id'],
|
|
|
- 'card_number' => ['sometimes', 'string', 'min:13', 'max:19'],
|
|
|
+ 'token' => ['sometimes', 'string', 'max:255'],
|
|
|
+ 'card_number' => ['sometimes', 'nullable', 'string', 'min:13', 'max:19'],
|
|
|
'holder_name' => ['sometimes', 'string', 'max:255'],
|
|
|
'expiration' => ['sometimes', 'string', 'regex:/^(0[1-9]|1[0-2])\/\d{4}$/'],
|
|
|
- 'cvv' => ['sometimes', 'string', 'min:3', 'max:4'],
|
|
|
+ 'cvv' => ['sometimes', 'nullable', 'string', 'min:3', 'max:4'],
|
|
|
'card_name' => ['nullable', 'string', 'max:255'],
|
|
|
'brand' => ['nullable', 'string', 'max:50'],
|
|
|
'last_four_digits' => ['sometimes', 'string', 'size:4'],
|
|
|
@@ -27,10 +28,11 @@ class ClientPaymentMethodRequest extends FormRequest
|
|
|
|
|
|
if ($this->isMethod('POST')) {
|
|
|
$rules['client_id'] = ['required', 'integer', 'exists:clients,id'];
|
|
|
- $rules['card_number'] = ['required', 'string', 'min:13', 'max:19'];
|
|
|
+ $rules['token'] = ['required', 'string', 'max:255'];
|
|
|
+ $rules['card_number'] = ['sometimes', 'nullable', 'string', 'min:13', 'max:19'];
|
|
|
$rules['holder_name'] = ['required', 'string', 'max:255'];
|
|
|
$rules['expiration'] = ['required', 'string', 'regex:/^(0[1-9]|1[0-2])\/\d{4}$/'];
|
|
|
- $rules['cvv'] = ['required', 'string', 'min:3', 'max:4'];
|
|
|
+ $rules['cvv'] = ['sometimes', 'nullable', 'string', 'min:3', 'max:4'];
|
|
|
$rules['last_four_digits'] = ['required', 'string', 'size:4'];
|
|
|
}
|
|
|
|
|
|
@@ -42,6 +44,7 @@ class ClientPaymentMethodRequest extends FormRequest
|
|
|
return [
|
|
|
'client_id.required' => 'O cliente é obrigatório.',
|
|
|
'client_id.exists' => 'Cliente não encontrado.',
|
|
|
+ 'token.required' => 'O token do cartão é obrigatório.',
|
|
|
'card_number.required' => 'O número do cartão é obrigatório.',
|
|
|
'card_number.min' => 'O número do cartão deve ter no mínimo 13 dígitos.',
|
|
|
'card_number.max' => 'O número do cartão deve ter no máximo 19 dígitos.',
|