|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Administrador |
|
5
|
|
|
* Date: 08/08/2017 |
|
6
|
|
|
* Time: 10:00 AM |
|
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 ShipmentValidator |
|
16
|
|
|
* @package Greenter\Xml\Validator |
|
17
|
|
|
*/ |
|
18
|
|
|
trait ShipmentValidator |
|
19
|
|
|
{ |
|
20
|
|
|
public static function loadValidatorMetadata(ClassMetadata $metadata) |
|
21
|
|
|
{ |
|
22
|
|
|
$metadata->addPropertyConstraints('codTraslado', [ |
|
23
|
|
|
new Assert\NotBlank(), |
|
24
|
|
|
new Assert\Length(['min' => 2, 'max' => 2]), |
|
25
|
|
|
]); |
|
26
|
|
|
$metadata->addPropertyConstraint('desTraslado', new Assert\Length(['max' => 100])); |
|
27
|
|
|
$metadata->addPropertyConstraint('indTransbordo', new Assert\NotBlank()); |
|
28
|
|
|
$metadata->addPropertyConstraint('pesoTotal', new Assert\NotBlank()); |
|
29
|
|
|
$metadata->addPropertyConstraints('undPesoTotal', [ |
|
30
|
|
|
new Assert\NotBlank(), |
|
31
|
|
|
new Assert\Length(['max' => 4]), |
|
32
|
|
|
]); |
|
33
|
|
|
$metadata->addPropertyConstraints('modTraslado', [ |
|
34
|
|
|
new Assert\NotBlank(), |
|
35
|
|
|
new Assert\Length(['min' => 2, 'max' => 2]), |
|
36
|
|
|
]); |
|
37
|
|
|
$metadata->addPropertyConstraints('fecTraslado', [ |
|
38
|
|
|
new Assert\NotBlank(), |
|
39
|
|
|
new Assert\Date() |
|
40
|
|
|
]); |
|
41
|
|
|
$metadata->addPropertyConstraint('numContenedor', new Assert\Length(['max' => 17])); |
|
42
|
|
|
$metadata->addPropertyConstraint('codPuerto', new Assert\Length(['max' => 3])); |
|
43
|
|
|
$metadata->addPropertyConstraint('transportista', new Assert\Valid()); |
|
44
|
|
|
$metadata->addPropertyConstraint('llegada', new Assert\Valid()); |
|
45
|
|
|
$metadata->addPropertyConstraint('partida', new Assert\Valid()); |
|
46
|
|
|
} |
|
47
|
|
|
} |