|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Giansalex |
|
5
|
|
|
* Date: 18/07/2017 |
|
6
|
|
|
* Time: 22:27 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Greenter\Xml\Validator; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata; |
|
12
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Trait NoteValidator |
|
16
|
|
|
* @package Greenter\Xml\Validator |
|
17
|
|
|
*/ |
|
18
|
|
|
trait NoteValidator |
|
19
|
|
|
{ |
|
20
|
6 |
|
public static function loadValidatorMetadata(ClassMetadata $metadata) |
|
21
|
|
|
{ |
|
22
|
6 |
|
$metadata->addPropertyConstraints('tipoDoc', [ |
|
23
|
6 |
|
new Assert\NotBlank(), |
|
24
|
6 |
|
new Assert\Length([ |
|
25
|
6 |
|
'min' => 2, |
|
26
|
6 |
|
'max' => 2, |
|
27
|
6 |
|
]), |
|
28
|
6 |
|
]); |
|
29
|
6 |
|
$metadata->addPropertyConstraints('serie', [ |
|
30
|
6 |
|
new Assert\NotBlank(), |
|
31
|
6 |
|
new Assert\Length([ 'max' => 4]), |
|
32
|
6 |
|
]); |
|
33
|
6 |
|
$metadata->addPropertyConstraints('correlativo', [ |
|
34
|
6 |
|
new Assert\NotBlank(), |
|
35
|
6 |
|
new Assert\Length(['max' => 8]), |
|
36
|
6 |
|
]); |
|
37
|
6 |
|
$metadata->addPropertyConstraint('fechaEmision', new Assert\Date()); |
|
38
|
6 |
|
$metadata->addPropertyConstraints('tipoDocUsuario', [ |
|
39
|
6 |
|
new Assert\NotBlank(), |
|
40
|
6 |
|
new Assert\Length(['max' => 1]), |
|
41
|
6 |
|
]); |
|
42
|
6 |
|
$metadata->addPropertyConstraints('numDocUsuario', [ |
|
43
|
6 |
|
new Assert\NotBlank(), |
|
44
|
6 |
|
new Assert\Length(['max' => 15]), |
|
45
|
6 |
|
]); |
|
46
|
6 |
|
$metadata->addPropertyConstraints('rznSocialUsuario', [ |
|
47
|
6 |
|
new Assert\NotBlank(), |
|
48
|
6 |
|
new Assert\Length(['max' => 100]), |
|
49
|
6 |
|
]); |
|
50
|
6 |
|
$metadata->addPropertyConstraints('tipoMoneda', [ |
|
51
|
6 |
|
new Assert\NotBlank(), |
|
52
|
6 |
|
new Assert\Length(['max' => 3]), |
|
53
|
6 |
|
]); |
|
54
|
6 |
|
$metadata->addPropertyConstraint('mtoOperGravadas', new Assert\NotBlank()); |
|
55
|
6 |
|
$metadata->addPropertyConstraint('mtoOperInafectas', new Assert\NotBlank()); |
|
56
|
6 |
|
$metadata->addPropertyConstraint('mtoOperExoneradas', new Assert\NotBlank()); |
|
57
|
6 |
|
$metadata->addPropertyConstraint('mtoImpVenta', new Assert\NotBlank()); |
|
58
|
6 |
|
$metadata->addPropertyConstraint('details', new Assert\Valid()); |
|
59
|
6 |
|
$metadata->addPropertyConstraint('legends', new Assert\Valid()); |
|
60
|
6 |
|
$metadata->addPropertyConstraint('relDocs', new Assert\Valid()); |
|
61
|
6 |
|
$metadata->addPropertyConstraints('codMotivo', [ |
|
62
|
6 |
|
new Assert\NotBlank(), |
|
63
|
6 |
|
new Assert\Length([ |
|
64
|
6 |
|
'min' => 2, |
|
65
|
6 |
|
'max' => 2, |
|
66
|
6 |
|
]), |
|
67
|
6 |
|
]); |
|
68
|
6 |
|
$metadata->addPropertyConstraints('desMotivo', [ |
|
69
|
6 |
|
new Assert\NotBlank(), |
|
70
|
6 |
|
new Assert\Length([ 'max' => 250]), |
|
71
|
6 |
|
]); |
|
72
|
6 |
|
$metadata->addPropertyConstraints('tipDocAfectado', [ |
|
73
|
6 |
|
new Assert\NotBlank(), |
|
74
|
6 |
|
new Assert\Length([ |
|
75
|
6 |
|
'min' => 2, |
|
76
|
6 |
|
'max' => 2, |
|
77
|
6 |
|
]), |
|
78
|
6 |
|
]); |
|
79
|
6 |
|
$metadata->addPropertyConstraints('numDocfectado', [ |
|
80
|
6 |
|
new Assert\NotBlank(), |
|
81
|
6 |
|
new Assert\Length([ 'max' => 13]), |
|
82
|
6 |
|
]); |
|
83
|
|
|
} |
|
84
|
|
|
} |