refactor: add regex validation for 'nama' field in AdditionalRequest

This commit is contained in:
LailaWulandarii 2026-02-06 15:40:47 +07:00
parent a7f78f4949
commit 921380e531
1 changed files with 2 additions and 1 deletions

View File

@ -16,7 +16,7 @@ public function authorize(): bool
public function rules(): array
{
return [
'nama' => 'required|string|min:3|max:100',
'nama' => 'required|string|min:3|max:100||regex:/^[a-zA-Z0-9\s\.,:"-]+$/',
'harga' => 'required|numeric|min:0',
];
}
@ -27,6 +27,7 @@ public function messages(): array
'required' => 'Kolom :attribute wajib diisi.',
'numeric' => ':attribute harus berupa angka.',
'string' => 'Input :attribute harus berupa teks valid.',
'regex' => ':attribute hanya boleh berisi huruf, angka, spasi, titik, koma, tanda hubung dan tanda petik dua.',
'min' => ':attribute minimal harus :min karakter/nilai.',
'max' => ':attribute melebihi batas maksimal :max karakter.',
];