Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| StoreParameterRequest | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| rules | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| messages | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v2\Parameter; |
| 4 | |
| 5 | use App\Http\Requests\v2\Parameter\Concerns\AuthorizesVengresoAdmin; |
| 6 | use Illuminate\Foundation\Http\FormRequest; |
| 7 | |
| 8 | /** |
| 9 | * Request for creating a new parameter. |
| 10 | * |
| 11 | * @property string $name The unique name/key of the parameter |
| 12 | * @property mixed $value The parameter value (string, number, boolean, array, object, or null) |
| 13 | */ |
| 14 | class StoreParameterRequest extends FormRequest |
| 15 | { |
| 16 | use AuthorizesVengresoAdmin; |
| 17 | |
| 18 | /** |
| 19 | * Get the validation rules that apply to the request. |
| 20 | * |
| 21 | * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
| 22 | */ |
| 23 | public function rules(): array |
| 24 | { |
| 25 | return [ |
| 26 | 'name' => 'required|string|max:255|unique:parameters,name', |
| 27 | 'value' => 'present', |
| 28 | ]; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get custom messages for validator errors. |
| 33 | * |
| 34 | * @return array<string, string> |
| 35 | */ |
| 36 | public function messages(): array |
| 37 | { |
| 38 | return [ |
| 39 | 'name.unique' => 'A parameter with this name already exists.', |
| 40 | 'value.present' => 'The value field must be present (can be null).', |
| 41 | ]; |
| 42 | } |
| 43 | } |