Documentation
This commit is contained in:
parent
93e94be9c4
commit
6228fc0e6d
|
@ -4,3 +4,8 @@ csv-validator
|
||||||
CSV validator library.
|
CSV validator library.
|
||||||
|
|
||||||
Works in progress. You should not use this package.
|
Works in progress. You should not use this package.
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
Read the source of `example.php`.
|
||||||
|
|
25
example.php
25
example.php
|
@ -10,11 +10,28 @@ chdir(__DIR__);
|
||||||
|
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
$parser = new CsvParser('lqdn.txt', ';', '');
|
$parser = new CsvParser('example.csv', ';', '');
|
||||||
|
|
||||||
$validator = new Validator($parser, Validation::createValidator());
|
$validator = new Validator($parser, Validation::createValidator());
|
||||||
$validator->addFieldConstraint(1, new Email());
|
|
||||||
|
$validator->addFieldConstraint(0, new Email());
|
||||||
|
$validator->addFieldConstraint(1, new Date());
|
||||||
|
|
||||||
$validator->validate();
|
$validator->validate();
|
||||||
|
|
||||||
var_dump($validator->isValid());
|
if ($validator->isValid() === false) {
|
||||||
var_dump($validator->getErrors());
|
foreach ($validator->getErrors() as $violation) {
|
||||||
|
$line = $violation->getLine();
|
||||||
|
$column = $violation->getColumn();
|
||||||
|
$message = $violation->getViolation()->getMessage();
|
||||||
|
|
||||||
|
echo <<<EOF
|
||||||
|
Line : $line
|
||||||
|
Column : $column
|
||||||
|
Message: $message
|
||||||
|
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
8
tests/CsvTest.php
Normal file
8
tests/CsvTest.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testAddLine()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue