Fixes for client validation

This commit is contained in:
David Bomba 2025-04-30 13:33:35 +10:00
parent 4a60371da0
commit e5df6754fe
3 changed files with 44 additions and 8 deletions

View File

@ -43,6 +43,8 @@ class StoreBankTransactionRequest extends Request
$rules['bank_integration_id'] = 'bail|required|exists:bank_integrations,id,company_id,'.$user->company()->id.',is_deleted,0';
$rules['amount'] = ['sometimes', 'bail', 'numeric', 'nullable', 'max:99999999999999'];
$rules['base_type'] = ['required','in:debit,credit', 'bail'];
return $rules;
}

View File

@ -75,10 +75,26 @@ class StoreClientRequest extends Request
$rules['shipping_country_id'] = 'integer|nullable|exists:countries,id';
$rules['number'] = ['sometimes', 'nullable', 'bail', Rule::unique('clients')->where('company_id', $user->company()->id)];
$rules['country_id'] = 'integer|nullable|exists:countries,id';
$rules['custom_value1'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value2'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value3'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value4'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value1'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
$rules['custom_value2'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
$rules['custom_value3'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
$rules['custom_value4'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
return $rules;
}

View File

@ -75,10 +75,28 @@ class UpdateClientRequest extends Request
//'regex:/[@$!%*#?&.]/', // must contain a special character
];
$rules['custom_value1'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value2'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value3'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value4'] = 'bail|nullable|sometimes|alpha_num';
$rules['custom_value1'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
$rules['custom_value2'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
$rules['custom_value3'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
$rules['custom_value4'] = ['bail','nullable','sometimes',function ($attribute, $value, $fail) {
if (is_array($value)) {
$fail("The $attribute must not be an array.");
}
}];
return $rules;
}