-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* coding style fixes, minor refactoring * added DatapackageValidator (depends on SchemaValidator from frictionlessdata/tableschema) * added basic datapackage validation functionality
- Loading branch information
Showing
18 changed files
with
949 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php namespace frictionlessdata\datapackage; | ||
|
||
// TODO: move the SchemaValidation logic to it's own independent package | ||
use frictionlessdata\tableschema; | ||
|
||
class DatapackageValidationError extends tableschema\SchemaValidationError | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php namespace frictionlessdata\datapackage; | ||
|
||
// TODO: move the SchemaValidation logic to it's own independent package | ||
use frictionlessdata\tableschema; | ||
|
||
class DatapackageValidator extends tableschema\SchemaValidator | ||
{ | ||
public static function validate($descriptor) | ||
{ | ||
$validator = new self($descriptor); | ||
return $validator->get_validation_errors(); | ||
} | ||
|
||
protected function _validateSchema() | ||
{ | ||
// Validate | ||
$validator = new \JsonSchema\Validator(); | ||
$validator->validate( | ||
$this->descriptor, (object)[ | ||
'$ref' => 'file://' . realpath(dirname(__FILE__)).'/schemas/data-package.json' | ||
] | ||
); | ||
if (!$validator->isValid()) { | ||
foreach ($validator->getErrors() as $error) { | ||
$this->_addError( | ||
DatapackageValidationError::SCHEMA_VIOLATION, | ||
sprintf("[%s] %s", $error['property'], $error['message']) | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
namespace frictionlessdata\datapackage\Exceptions; | ||
|
||
class DataStreamOpenException extends \Exception { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
namespace frictionlessdata\datapackage\Exceptions; | ||
|
||
class DatapackageInvalidSourceException extends \Exception { | ||
|
||
} |
Oops, something went wrong.