Skip to content

Commit 36be8ac

Browse files
committed
feat: add option to return full data
1 parent a7db414 commit 36be8ac

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Request.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,19 @@ public static function headers($key = null, bool $safeData = true)
310310
* Validate the request data
311311
*
312312
* @param array $rules The rules to validate against
313+
* @param boolean $returnFullData Return the full data or just the validated data?
313314
*
314315
* @return false|array Returns false if validation fails, or the validated data if validation passes
315316
*/
316-
public static function validate(array $rules)
317+
public static function validate(array $rules, bool $returnFullData = false)
317318
{
318319
$data = \Leaf\Form::validate(static::body(false), $rules);
319320

320321
if ($data === false) {
321322
return false;
322323
}
323324

324-
return static::body();
325+
return $returnFullData ? $data : static::get(array_keys($rules));
325326
}
326327

327328
/**
@@ -331,7 +332,7 @@ public static function validate(array $rules)
331332
protected static function auth()
332333
{
333334
if (!class_exists('\Leaf\Auth')) {
334-
throw new \Exception("You need to install the leafs/auth package to use the auth helper");
335+
throw new \Exception('You need to install the leafs/auth package to use the auth helper');
335336
}
336337

337338
if (!(\Leaf\Config::get('auth.instance'))) {

0 commit comments

Comments
 (0)