60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
final class CityRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
// 市区名:全角文字列 / 必須 / 1〜20文字
|
|
'city_name' => [
|
|
'required',
|
|
'string',
|
|
'min:1',
|
|
'max:20',
|
|
'regex:/^[^ -~。-゚]+$/u',
|
|
],
|
|
|
|
// 印字レイアウトファイル:半角英数字 / 必須 / 1〜255文字
|
|
'print_layout' => [
|
|
'required',
|
|
'string',
|
|
'min:1',
|
|
'max:255',
|
|
'regex:/^[A-Za-z0-9]+$/',
|
|
],
|
|
|
|
// 備考:任意文字列 / 最大255
|
|
'city_remarks' => [
|
|
'nullable',
|
|
'string',
|
|
'max:255',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'city_name.required' => '市区名は必須です。',
|
|
'city_name.regex' => '市区名は全角文字で入力してください。',
|
|
'city_name.max' => '市区名は20文字以内で入力してください。',
|
|
|
|
'print_layout.required' => '印字レイアウトファイルは必須です。',
|
|
'print_layout.regex' => '印字レイアウトファイルは半角英数字で入力してください。',
|
|
'print_layout.max' => '印字レイアウトファイルは255文字以内で入力してください。',
|
|
|
|
'city_remarks.max' => '備考は255文字以内で入力してください。',
|
|
];
|
|
}
|
|
}
|