Skip to content

Commit

Permalink
helper for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mzhelskiy committed Jan 27, 2017
1 parent 8c532cc commit 99805d4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions classes/modules/validate/Validate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,24 @@ public function ClearErrors()
{
$this->aErrors = array();
}

/**
* Хелпер для подготовки списка ошибок при передаче в js
*
* @param $aErrors
* @param null $sWrapField
* @param array $aSkipWrapFields
* @return array
*/
public function PrepareValidateErrors($aErrors, $sWrapField = null, $aSkipWrapFields = array())
{
$aResult = array();
foreach ($aErrors as $sField => $aErrorsItem) {
if ($sWrapField and !in_array($sField, $aSkipWrapFields)) {
$sField = str_replace('*', $sField, $sWrapField);
}
$aResult[$sField] = $aErrorsItem;
}
return $aResult;
}
}

0 comments on commit 99805d4

Please sign in to comment.