Skip to content

Commit

Permalink
Added Validation::errorInputs() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
zntr committed Dec 18, 2022
1 parent afa8a92 commit 66167f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
18 changes: 17 additions & 1 deletion Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,17 @@ public function messages(array $settings)
* Add errors
*
* @param string $error
* @param string $name = NULL
*
* @return self
*/
public function addError(string $error)
public function addError(string $error, string $name = NULL)
{
if( $name )
{
$this->error[$name] = $error;
}

$this->errors[][$this->index] = $error . '<br>'; $this->index++;
}

Expand Down Expand Up @@ -266,6 +272,16 @@ public function postBack(string $name, string $met = 'post')
return $method;
}

/**
* Get error inputs.
*
* @return array
*/
public function errorInputs()
{
return array_keys($this->error);
}

/**
* Protected is validator object
*/
Expand Down
10 changes: 9 additions & 1 deletion DataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public function messages(array $settings);
* Add errors
*
* @param string $error
* @param string $name = NULL
*
* @return self
*/
public function addError(string $error);
public function addError(string $error, string $name = NULL);

/**
* Get error
Expand All @@ -63,4 +64,11 @@ public function error(String $name = 'array', string $separator = '<br>');
* @param string $met = 'post' - options[post|get]
*/
public function postBack(string $name, string $met = 'post');

/**
* Get error inputs.
*
* @return array
*/
public function errorInputs();
}

0 comments on commit 66167f4

Please sign in to comment.