-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Se agrega clase DocumentoValidator y se integra en flujo de normaliza…
…ción de datos de un DTE como última etapa.
- Loading branch information
1 parent
833192c
commit 256ff6f
Showing
8 changed files
with
84 additions
and
2 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
57 changes: 57 additions & 0 deletions
57
src/Sii/Dte/Documento/Normalization/DocumentoValidator.php
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* LibreDTE: Biblioteca PHP (Núcleo). | ||
* Copyright (C) LibreDTE <https://www.libredte.cl> | ||
* | ||
* Este programa es software libre: usted puede redistribuirlo y/o modificarlo | ||
* bajo los términos de la Licencia Pública General Affero de GNU publicada | ||
* por la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, | ||
* o (a su elección) cualquier versión posterior de la misma. | ||
* | ||
* Este programa se distribuye con la esperanza de que sea útil, pero SIN | ||
* GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD | ||
* PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la Licencia Pública | ||
* General Affero de GNU para obtener una información más detallada. | ||
* | ||
* Debería haber recibido una copia de la Licencia Pública General Affero de | ||
* GNU junto a este programa. | ||
* | ||
* En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>. | ||
*/ | ||
|
||
namespace libredte\lib\Core\Sii\Dte\Documento\Normalization; | ||
|
||
/** | ||
* Clase que maneja la validación de los datos de un documento. | ||
*/ | ||
class DocumentoValidator | ||
{ | ||
/** | ||
* Ejecuta la validación de los datos. | ||
* | ||
* @param array $data Arreglo con los datos del documento a validar. | ||
*/ | ||
public function validate(array $data): void | ||
{ | ||
$this->applyProValidation($data); | ||
} | ||
|
||
/** | ||
* Valida los datos del documento utilizando funcionalidades Pro. | ||
* | ||
* @param array $data Arreglo con los datos del documento a validar. | ||
* @throws DocumentoValidatorException | ||
*/ | ||
private function applyProValidation(array $data): void | ||
{ | ||
// Validar los datos con las funcionalidades Pro de la biblioteca. | ||
$class = '\libredte\lib\Pro\Sii\Dte\Documento\Normalization\DocumentoValidator'; | ||
if (class_exists($class)) { | ||
$validator = $class::create($this); | ||
$validator->validate($data); | ||
} | ||
} | ||
} |
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