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

@ -23,6 +23,9 @@ $validator->addFieldConstraint(0, new Email());
// The second field must contain a date
$validator->addFieldConstraint(1, new Date());
// Validate the legend
$validator->setExceptedLegend(array('foo', 'bar', 'bim'));
// An line must contain 3 columns
$validator->addDataConstraint(new Callback(function($data, ExecutionContextInterface $context) {
if (count($data) !== 6) { // 6 because of the legend (3 fields * 2)