Documentation
This commit is contained in:
parent
93e94be9c4
commit
6228fc0e6d
|
@ -4,3 +4,8 @@ csv-validator
|
|||
CSV validator library.
|
||||
|
||||
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';
|
||||
|
||||
$parser = new CsvParser('lqdn.txt', ';', '');
|
||||
$parser = new CsvParser('example.csv', ';', '');
|
||||
|
||||
$validator = new Validator($parser, Validation::createValidator());
|
||||
$validator->addFieldConstraint(1, new Email());
|
||||
|
||||
$validator->addFieldConstraint(0, new Email());
|
||||
$validator->addFieldConstraint(1, new Date());
|
||||
|
||||
$validator->validate();
|
||||
|
||||
var_dump($validator->isValid());
|
||||
var_dump($validator->getErrors());
|
||||
if ($validator->isValid() === false) {
|
||||
foreach ($validator->getErrors() as $violation) {
|
||||
$line = $violation->getLine();
|
||||
$column = $violation->getColumn();
|
||||
$message = $violation->getViolation()->getMessage();
|
||||
|
||||
echo <<<EOF
|
||||
Line : $line
|
||||
Column : $column
|
||||
Message: $message
|
||||
|
||||
|
||||
EOF;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
class ValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAddLine()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue