*/ public function rules() { return [ 'translate.name_short' => 'required|string|min:2|max:100', 'translate.name_detail' => 'required|string|min:2|max:100', 'translate.description' => 'required|string|min:2|max:65535', 'active' => 'sometimes|accepted', 'model' => 'sometimes|string', // @todo Check that it is a valid model type 'model_id' => 'sometimes|int', // @todo Check that it is a valid model type 'accounting' => [ 'nullable', 'array', function (string $attribute,mixed $value,\Closure $fail) { if (! is_array($value)) $fail("Invalid format for {$attribute}"); foreach ($value as $k=>$v) { if (! ProviderOauth::where('id',$k)->exists()) $fail("Provider doesnt exist [$k]"); // @todo Validate that the value is in the accounting system } }, ], 'pricing' => 'required|array', // @todo Validate the elements in the pricing ]; } }