public function initializeWithConstraints(array $constraints)
{
// Reset errors
$this->errors = array();
// Set existing constraint values to false
foreach ($this->constraints as $constraint => $value) {
$this->constraints[$constraint] = false;
}
// Initialize constraints with new values
foreach ($constraints as $constraint => $value) {
if (!isset($this->constraints[$constraint])) {
throw new PropertyNotFound("The constraint '{$constraint}' is not valid for this validator.");
}
$this->constraints[$constraint] = $value;
}
}