validate( $rules ?: (array) $this->rules(), $messages ?: (array) $this->messages() ); } catch (ValidationException $e) { if (defined('REST_REQUEST') && REST_REQUEST) { throw $e; } else { App::getInstance()->doCustomAction('handle_exception', $e); } } } /** * Handles validation including before and after calls * * @throws FluentSupport\Framework\Validator\ValidationException * @return null */ public static function applyValidation() { $instance = new static; $request = App::getInstance('request'); $request->merge($instance->beforeValidation()); $instance->validate(); $request->merge($instance->afterValidation()); } /** * Get an input element from the request. * * @param string $key * @return mixed */ public function __get($key) { return $this->get($key); } /** * Handle the dynamic method calls * @param string $method * @param array $params * @return mixed */ public function __call($method, $params) { return call_user_func_array( [App::make('request'), $method], $params ); } }