A modest collection of PHP libraries used at SparkFun.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

31 lines
638 B

<?php
namespace SparkLib;
use Exception;
/**
* An Exception class for when validation blows up. See SparkLib\Validator.
*/
class ValidatorException extends Exception {
protected $_failures = array();
public function __construct (array $failures)
{
$this->_failures = $failures;
// give the exception a somewhat readable error string
foreach ($failures as $field => $problem) {
$error_message = $field . ' ' . $problem;
}
parent::__construct($error_message);
}
/**
* @return associative array of validation failures
*/
public function getErrors ()
{
return $this->_failures;
}
}