Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
Simon Vieille | a2e1ac418c | ||
Simon Vieille | 2d06d4adc5 | ||
Simon Vieille | fac4371d69 | ||
Simon Vieille | 0b9c77ae7f | ||
Simon Vieille | cd43e2fed9 | ||
Simon Vieille | af0c45c6bc | ||
Simon Vieille | 6169083b5e | ||
Simon Vieille | 95c470e404 | ||
Simon Vieille | 78610d50ea | ||
Simon Vieille | 8ee01fc209 | ||
Simon Vieille | 1e6ed3d204 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1 @@
|
||||||
*.swp
|
|
||||||
tags
|
|
||||||
vendor
|
vendor
|
||||||
|
|
25
Jenkinsfile
vendored
Normal file
25
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('PHP 7.1') {
|
||||||
|
steps {
|
||||||
|
sh '/usr/local/bin/composer-php7.1 install'
|
||||||
|
sh 'php7.1 /usr/local/bin/phpunit-7'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('PHP 7.3') {
|
||||||
|
steps {
|
||||||
|
sh '/usr/local/bin/composer-php7.3 update'
|
||||||
|
sh 'php7.3 /usr/local/bin/phpunit-9'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('PHP 7.4') {
|
||||||
|
steps {
|
||||||
|
sh '/usr/local/bin/composer-php7.4 update'
|
||||||
|
sh 'php7.4 /usr/local/bin/phpunit-9'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
3
LICENSE
3
LICENSE
|
@ -20,4 +20,5 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
csv-validator
|
csv-validator
|
||||||
=============
|
=============
|
||||||
|
|
||||||
![](https://phpci.gitnet.fr//build-status/image/1)
|
[![Build Status](https://ci.gitnet.fr/buildStatus/icon?job=Gitnet%2Fcsv-validator%2F3)](https://ci.gitnet.fr/job/Gitnet/job/csv-validator/job/3/)
|
||||||
|
|
||||||
CSV validator library
|
CSV validator library
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6.0",
|
"php": "^7.1.3",
|
||||||
"symfony/validator": "2.*",
|
"symfony/validator": "^4",
|
||||||
"deblan/csv": "v2.0.*"
|
"deblan/csv": "v2.0.*|v3.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use Deblan\Csv\CsvParser;
|
use Deblan\Csv\CsvParser;
|
||||||
use Deblan\CsvValidator\Validator;
|
use Deblan\CsvValidator\Validator;
|
||||||
use Symfony\Component\Validator\Validation;
|
|
||||||
use Symfony\Component\Validator\Constraints\Email;
|
use Symfony\Component\Validator\Constraints\Email;
|
||||||
use Symfony\Component\Validator\Constraints\Date;
|
use Symfony\Component\Validator\Constraints\Date;
|
||||||
use Symfony\Component\Validator\Constraints\Callback;
|
use Symfony\Component\Validator\Constraints\Callback;
|
||||||
|
@ -23,7 +22,7 @@ $validator->addFieldConstraint(1, new Date());
|
||||||
$validator->setExpectedHeaders(['foo', 'bar', 'bim']);
|
$validator->setExpectedHeaders(['foo', 'bar', 'bim']);
|
||||||
|
|
||||||
// An line must contain 3 columns
|
// An line must contain 3 columns
|
||||||
$validator->addDataConstraint(new Callback(function($data, ExecutionContextInterface $context) {
|
$validator->addDataConstraint(new Callback(function ($data, ExecutionContextInterface $context) {
|
||||||
if (count($data) !== 6) { // 6 because of the legend (3 fields * 2)
|
if (count($data) !== 6) { // 6 because of the legend (3 fields * 2)
|
||||||
$context->addViolation('The line must contain 3 columns');
|
$context->addViolation('The line must contain 3 columns');
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
convertWarningsToExceptions = "true"
|
convertWarningsToExceptions = "true"
|
||||||
processIsolation = "false"
|
processIsolation = "false"
|
||||||
stopOnFailure = "false"
|
stopOnFailure = "false"
|
||||||
syntaxCheck = "false"
|
|
||||||
bootstrap = "vendor/autoload.php" >
|
bootstrap = "vendor/autoload.php" >
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
|
|
@ -122,6 +122,7 @@ class Validator
|
||||||
if ($this->parser !== $parser) {
|
if ($this->parser !== $parser) {
|
||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
$this->errors = [];
|
$this->errors = [];
|
||||||
|
$this->hasValidate = false;
|
||||||
} elseif ($this->hasValidate) {
|
} elseif ($this->hasValidate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class ExampleTest.
|
* class ExampleTest.
|
||||||
*
|
*
|
||||||
* @author Simon Vieille <simon@deblan.fr>
|
* @author Simon Vieille <simon@deblan.fr>
|
||||||
*/
|
*/
|
||||||
class ExampleTest extends \PHPUnit_Framework_TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testExemple()
|
public function testExemple()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use Deblan\Csv\CsvParser;
|
use Deblan\Csv\CsvParser;
|
||||||
use Deblan\CsvValidator\Validator;
|
use Deblan\CsvValidator\Validator;
|
||||||
use Symfony\Component\Validator\Validation;
|
use Symfony\Component\Validator\Validation;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Validator\Constraints\Email;
|
use Symfony\Component\Validator\Constraints\Email;
|
||||||
|
|
||||||
class ValidatorTest extends \PHPUnit_Framework_TestCase
|
class ValidatorTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testViolation()
|
public function testViolation()
|
||||||
{
|
{
|
||||||
$parser = $this->generateParser('example.csv');
|
$parser = $this->generateParser('example.csv');
|
||||||
$validator = $this->generateValidator($parser);
|
$validator = $this->generateValidator($parser);
|
||||||
$this->setExpectedException('\RuntimeException');
|
$this->expectException('\RuntimeException');
|
||||||
$validator->isValid();
|
$validator->isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Validator\ConstraintViolation;
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
use Deblan\CsvValidator\Violation;
|
use Deblan\CsvValidator\Violation;
|
||||||
|
|
||||||
class ViolationTest extends \PHPUnit_Framework_TestCase
|
class ViolationTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testViolation()
|
public function testViolation()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue