-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- test that JSON files converted via PHP validate against the JSON schema other changes: - supply malformed / incomplete test XML files - turn Xml2Json into a PHP class - add PHP unit tests with PHPunit - add PHP json validation script using `justinrainbow/json-schema` - add Test and Contributing sections in README - lint js, PHP & sh - add `bin/validate_xml.sh` script - update JSON schema to require NumeroColli, NumeroLinea, Numero
- Loading branch information
Paolo Greppi
committed
Jul 3, 2018
1 parent
4d4e150
commit 60680f1
Showing
36 changed files
with
2,476 additions
and
99 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
File renamed without changes.
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,27 @@ | ||
#!/usr/bin/php | ||
<?php | ||
// validates the supplied JSON invoice file against the JSON invoice schema | ||
// | ||
// Copyright (c) 2018, Paolo Greppi <[email protected]> | ||
// License: BSD 3-Clause | ||
|
||
require_once './vendor/autoload.php'; | ||
|
||
if (count($argv) <= 1) { | ||
echo "Usage: validate.php file.json\n"; | ||
exit(-1); | ||
} | ||
|
||
$filename = $argv[1]; | ||
$data = json_decode(file_get_contents($filename)); | ||
$validator = new JsonSchema\Validator; | ||
$validator->validate($data, (object)['$ref' => 'file://' . realpath('fatturaPA_1.2_schema.json')]); | ||
|
||
if ($validator->isValid()) { | ||
echo "The supplied JSON validates against the schema.\n"; | ||
} else { | ||
echo "JSON does not validate. Violations:\n"; | ||
foreach ($validator->getErrors() as $error) { | ||
echo sprintf("[%s] %s\n", $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
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,10 @@ | ||
#!/bin/sh | ||
# | ||
# validates against the XML invoice schema the supplied XML invoice file | ||
# | ||
# Copyright (c) 2018, Paolo Greppi <[email protected]> | ||
# License: BSD 3-Clause | ||
|
||
set -e | ||
|
||
xmllint --debug --schema Schema_del_file_xml_FatturaPA_versione_1.2_cleanup.xsd "$1" -noout |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"require": { | ||
"squizlabs/php_codesniffer": "*" | ||
"squizlabs/php_codesniffer": "*", | ||
"justinrainbow/json-schema": "^5.2" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.