Test the legend

This commit is contained in:
Simon Vieille 2016-05-22 23:38:17 +02:00
commit 522e7f9032
3 changed files with 33 additions and 1 deletions

View file

@ -89,6 +89,19 @@ class Validator
return $this;
}
/**
* Set the excepted legend
*
* @param array $legend Expected legend
* @return Validator
*/
public function setExceptedLegend(array $legend)
{
$this->expectedLegend = $legend;
return $this;
}
/**
* Run the validation
*/
@ -98,6 +111,7 @@ class Validator
return;
}
$this->validateLegend();
$this->validateDatas();
$this->validateFields();
@ -105,6 +119,21 @@ class Validator
$this->hasValidate = true;
}
protected function validateLegend()
{
if (!$this->parser->getHasLegend()) {
return;
}
if (null === $this->expectedLegend) {
return;
}
if ($this->parser->getLegend() !== $this->expectedLegend) {
$this->mergeErrorMessage('Invalid legend.', 1);
}
}
/**
* Validates datas
*/