From 36be8ac1c960f4c5581598cb901352fe3e986685 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Sat, 19 Aug 2023 20:18:15 +0000 Subject: [PATCH] feat: add option to return full data --- src/Request.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Request.php b/src/Request.php index 8aa694a..94e8c92 100755 --- a/src/Request.php +++ b/src/Request.php @@ -310,10 +310,11 @@ public static function headers($key = null, bool $safeData = true) * Validate the request data * * @param array $rules The rules to validate against + * @param boolean $returnFullData Return the full data or just the validated data? * * @return false|array Returns false if validation fails, or the validated data if validation passes */ - public static function validate(array $rules) + public static function validate(array $rules, bool $returnFullData = false) { $data = \Leaf\Form::validate(static::body(false), $rules); @@ -321,7 +322,7 @@ public static function validate(array $rules) return false; } - return static::body(); + return $returnFullData ? $data : static::get(array_keys($rules)); } /** @@ -331,7 +332,7 @@ public static function validate(array $rules) protected static function auth() { if (!class_exists('\Leaf\Auth')) { - throw new \Exception("You need to install the leafs/auth package to use the auth helper"); + throw new \Exception('You need to install the leafs/auth package to use the auth helper'); } if (!(\Leaf\Config::get('auth.instance'))) {