Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 29 | All time: 11,180 This week: 73![]() |
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}" ?????? ??????????? ?????.',
];
}
}
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | src |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
Class | Class source | ||
![]() |
Class | Class source | ||
![]() |
Class | Class source | ||
![]() |
Class | Class source | ||
![]() |
Class | Class source | ||
![]() |
Class | Class source | ||
![]() |
Class | Class source |
![]() |
/ | src | / | Exceptions |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
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.