Skip to content

Commit cb34895

Browse files
committed
✨ add the errorsAsArray(), configurationRules(), useExcept() and useOnly methods
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 8228782 commit cb34895

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

CodeIgniter/Framework/libraries/Form_validation.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,58 @@ public function errorsAsArray()
461461
return $this->_error_array;
462462
}
463463

464+
// --------------------------------------------------------------------
465+
466+
/**
467+
* Get Validation Rules From Configurations
468+
*
469+
* @return array
470+
*/
471+
public function configurationRules()
472+
{
473+
return $this->_config_rules;
474+
}
475+
476+
// --------------------------------------------------------------------
477+
478+
/**
479+
* Get All Validated Fields Except Specified Fields
480+
*
481+
* @param mixed $request
482+
* @return array
483+
*/
484+
public function useExcept(array $except)
485+
{
486+
487+
$fields = $this->validation_data;
488+
489+
foreach($except as $key) {
490+
unset($fields[$key]);
491+
}
492+
493+
return $fields;
494+
}
495+
496+
// --------------------------------------------------------------------
497+
498+
/**
499+
* Get Only Specified Fields From The Validated Fields
500+
*
501+
* @param array $only
502+
* @return array
503+
*/
504+
public function useOnly(array $only)
505+
{
506+
507+
$only = !is_array($only) ? [$only] : $only;
508+
509+
$fields = $this->validation_data;
510+
511+
return array_intersect_key($fields, array_flip($only));
512+
513+
}
514+
515+
// --------------------------------------------------------------------
464516

465517
/**
466518
* Error String

0 commit comments

Comments
 (0)