Skip to content
Snippets Groups Projects
Commit 3051b0e8 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

No commit message

No commit message
parent d86cca5f
No related branches found
No related tags found
No related merge requests found
<?php
class DataObjectValidator
{
private $status;
private $errors;
public function validateDataObject($dataObject, $schema)
{
$XmlDocument = $dataObject->asXmlDocument();
libxml_use_internal_errors(true);
if($XmlDocument->schemaValidateSource($schema->saveXML())) {
return true;
} else {
$libXMLErrors = libxml_get_errors();
foreach ($libXMLErrors as $libXMLError) {
$this->errors[] = new DataObjectValidatorError($libXMLError);
}
return false;
}
libxml_clear_errors();
}
function getErrors()
{
return $this->errors;
}
}
class DataObjectValidatorError
{
function DataObjectValidatorError($libXMLError)
{
$this->level = $libXMLError->level;
$this->code = 'XML-' . $libXMLError->code;
$this->message = $libXMLError->message;
}
}
\ No newline at end of file
<?php
class message
{
public $level;
public $code;
public $text;
function message($level, $code, $text)
{
$this->level = $level;
$this->code = $code;
$this->text = $text;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment