Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (19) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-03-19 (4 days ago) | Not enough user ratings | Total: 19 This week: 19 | All time: 11,185 This week: 4 |
Version | License | PHP version | Categories | |||
validator-xsd 1.0 | MIT/X Consortium ... | 7 | XML, Validation, PHP 7 |
Description | Author | |
This package can validate XML documents with XSD schema files. |
ValidatorXSD is a DOMDocument facade that will allow you to more conveniently validate your XML file and also localize errors.
The package can be installed via composer:
composer require yzen.dev/validator-xsd
Validate xml by schema:
$data = '<XML>...</XML>';
$validator = ValidatorXSD::init($data)
->loadSchema( './XSD/request.xsd')
->setLocalization(CustomLocalizationXSD::class);
echo $validator->validate();
Get all error:
if (!$validator->validate()) {
foreach ($validator->getErrors() as $error) {
var_dump($error);
}
}
Pluck result and group by field:
$errors = $validator->getErrors()
->pluck(['element','message'])
->groupBy('element');
Create custom localization
class CustomLocalizationXSD implements LocalizationXSD
{
public function customAttributes(): array
{
return [
'Country' => '??????',
'Province' => '???????',
];
}
public function messages(): array
{
return [
'minLength' => '???? "${field}" ?????? ??????????? ?????.',
];
}
}
Files |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
src (7 files, 1 directory) | ||||
tests (1 file, 1 directory) | ||||
.editorconfig | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpcs.xml | Data | Auxiliary data | ||
phpstan.neon | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
Exceptions (1 file) | ||||
Collection.php | Class | Class source | ||
CollectionErrorXSD.php | Class | Class source | ||
ErrorXSD.php | Class | Class source | ||
LocalizationXSD.php | Class | Class source | ||
ParseLibXMLError.php | Class | Class source | ||
Translator.php | Class | Class source | ||
ValidatorXSD.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.