['required', 'string', 'max:50', 'regex:/^[a-zA-Z][a-zA-Z0-9_]*$/'], 'label' => ['required', 'string', 'max:100'], 'type' => ['required', 'string', 'in:INPUT,OUTPUT'], 'data_type' => ['required', 'string', 'in:INTEGER,DECIMAL,STRING,BOOLEAN'], 'unit' => ['nullable', 'string', 'max:20'], 'default_value' => ['nullable', 'string', 'max:255'], 'min_value' => ['nullable', 'numeric'], 'max_value' => ['nullable', 'numeric', 'gte:min_value'], 'enum_values' => ['nullable', 'array'], 'enum_values.*' => ['string', 'max:100'], 'validation_rules' => ['nullable', 'string', 'max:500'], 'description' => ['nullable', 'string', 'max:500'], 'is_required' => ['boolean'], 'display_order' => ['integer', 'min:0'], ]; } /** * Get custom messages for validator errors. */ public function messages(): array { return [ 'name.regex' => __('validation.model_parameter.name_format'), 'max_value.gte' => __('validation.model_parameter.max_value_gte_min'), ]; } /** * Get custom attribute names for validator errors. */ public function attributes(): array { return [ 'name' => __('validation.attributes.parameter_name'), 'label' => __('validation.attributes.parameter_label'), 'type' => __('validation.attributes.parameter_type'), 'data_type' => __('validation.attributes.data_type'), 'unit' => __('validation.attributes.unit'), 'default_value' => __('validation.attributes.default_value'), 'min_value' => __('validation.attributes.min_value'), 'max_value' => __('validation.attributes.max_value'), 'enum_values' => __('validation.attributes.enum_values'), 'validation_rules' => __('validation.attributes.validation_rules'), 'description' => __('validation.attributes.description'), 'is_required' => __('validation.attributes.is_required'), 'display_order' => __('validation.attributes.display_order'), ]; } /** * Prepare the data for validation. */ protected function prepareForValidation(): void { $this->merge([ 'is_required' => $this->boolean('is_required'), 'display_order' => $this->integer('display_order', 0), ]); } }