omegacode / php-parsecsv-validator
此包已被弃用且不再维护。未建议替代包。
此库为验证CSV对象添加了一些验证API。
1.0.0
2018-11-26 10:09 UTC
Requires
- php: ^5.6 || ^7.0
- parsecsv/php-parsecsv: ^1.1
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2020-01-19 19:19:00 UTC
README
描述
此库为验证CSV对象添加了一些验证API。对象必须是ParseCsv\Csv
类型。
如何使用
$header = ['title', 'price', 'categories', 'attributes']; $reqHeaders = ['title', 'price']; $validator = new CsvValidator($csv); $validator ->validateHeadersAreEqual($header) ->validateDataStructure($header) ->validateDataForRequiredHeaders($reqHeaders]) ; if (count($validator->getErrors() > 0) { // file is invalid. check the errors. } else { // file is valid. continue coding. }