add new validation rule and validation message for foto crud
This commit is contained in:
parent
94cc8cd1ef
commit
cfd11ecb9d
|
|
@ -16,10 +16,10 @@ public function authorize(): bool
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'nama' => 'required|string|min:3|max:100|regex:/^[a-zA-Z0-9\s\.,:"-]+$/',
|
'nama' => 'required|string|min:3|max:50|regex:/^[a-zA-Z0-9\s\.\:\(\)\"\-\,]+$/',
|
||||||
'harga' => 'required|numeric|min:0',
|
'harga' => 'required|numeric|min:0',
|
||||||
'durasi' => 'required|integer|min:0',
|
'durasi' => 'required|integer|min:0',
|
||||||
'deskripsi' => 'required|string|min:10|regex:/^[a-zA-Z0-9\s\.,:"-]+$/',
|
'deskripsi' => 'required|string|min:3|max:170|regex:/^[a-zA-Z0-9\s\.\:\(\)\"\-\,]+$/',
|
||||||
'foto' => $this->isMethod('post')
|
'foto' => $this->isMethod('post')
|
||||||
? 'required|image|mimes:jpeg,png,jpg|max:2048'
|
? 'required|image|mimes:jpeg,png,jpg|max:2048'
|
||||||
: 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
: 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
||||||
|
|
@ -29,12 +29,14 @@ public function rules(): array
|
||||||
public function messages(): array
|
public function messages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'required' => 'Kolom :attribute wajib diisi.',
|
'required' => ':attribute wajib diisi.',
|
||||||
'string' => 'Input :attribute harus berupa teks valid.',
|
'numeric' => ':attribute harus berupa angka.',
|
||||||
|
'string' => ':attribute harus berupa teks valid.',
|
||||||
'integer' => 'Input :attribute harus berupa angka valid.',
|
'integer' => 'Input :attribute harus berupa angka valid.',
|
||||||
'numeric' => ':attribute harus berupa angka.',
|
'numeric' => ':attribute harus berupa angka.',
|
||||||
'min' => ':attribute minimal harus :min karakter/nilai.',
|
'regex' => ':attribute hanya boleh berisi huruf, angka, spasi, titik, koma, titik dua, tanda hubung, tanda kurung, garis miring, dan tanda petik dua.',
|
||||||
'max' => ':attribute melebihi batas, maksimal :max karakter/KB.',
|
'min' => ':attribute terlalu pendek, minimal :min karakter.',
|
||||||
|
'max' => ':attribute terlalu panjang, maksimal :max karakter.',
|
||||||
'image' => ':attribute harus berupa file gambar (foto).',
|
'image' => ':attribute harus berupa file gambar (foto).',
|
||||||
'mimes' => 'Format :attribute tidak didukung (jpeg, png, jpg).',
|
'mimes' => 'Format :attribute tidak didukung (jpeg, png, jpg).',
|
||||||
'foto.max' => 'Ukuran :attribute maksimal 2MB.',
|
'foto.max' => 'Ukuran :attribute maksimal 2MB.',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue