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