First version
This commit is contained in:
parent
7622c3f5fa
commit
8f6b4afe5b
|
@ -1,4 +1,6 @@
|
||||||
csv-validator
|
csv-validator
|
||||||
=============
|
=============
|
||||||
|
|
||||||
CSV validator library
|
CSV validator library.
|
||||||
|
|
||||||
|
Works in progress. You should not use this package.
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-4": {
|
||||||
"": "src/"
|
"Deblan\\CsvValidator\\": "src/Deblan/CsvValidator/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Deblan\Validator\Constraints;
|
namespace Deblan\CsvValidator\Constraints;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\File;
|
use Symfony\Component\Validator\Constraints\File;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Deblan\Validator\Constraints;
|
namespace Deblan\CsvValidator\Constraints;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\FileValidator;
|
use Symfony\Component\Validator\Constraints\FileValidator;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
|
@ -4,8 +4,8 @@ namespace Deblan\CsvValidator;
|
||||||
|
|
||||||
use Deblan\Csv\CsvParser;
|
use Deblan\Csv\CsvParser;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\Validator\LegacyValidator;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationList;
|
use Symfony\Component\Validator\ConstraintViolationList;
|
||||||
|
use Symfony\Component\Validator\Validator\RecursiveValidator;
|
||||||
|
|
||||||
class Validator
|
class Validator
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ class Validator
|
||||||
|
|
||||||
protected $errors = [];
|
protected $errors = [];
|
||||||
|
|
||||||
public function __construct(CsvParser $parser, LegacyValidator $validator)
|
public function __construct(CsvParser $parser, RecursiveValidator $validator)
|
||||||
{
|
{
|
||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
$this->parser->parse();
|
$this->parser->parse();
|
||||||
|
@ -77,6 +77,10 @@ class Validator
|
||||||
|
|
||||||
protected function mergeViolationsMessages(ConstraintViolationList $violations, $line, $key = null)
|
protected function mergeViolationsMessages(ConstraintViolationList $violations, $line, $key = null)
|
||||||
{
|
{
|
||||||
|
if (count($violations) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!array_key_exists($line, $this->errors)) {
|
if (!array_key_exists($line, $this->errors)) {
|
||||||
$this->errors[$line] = [];
|
$this->errors[$line] = [];
|
||||||
}
|
}
|
Loading…
Reference in a new issue