@@ 12-25 (lines=14) @@ | ||
9 | /** |
|
10 | * @author Sullivan Senechal <[email protected]> |
|
11 | */ |
|
12 | final class IpValidator extends AbstractIsoCodesConstraintValidator |
|
13 | { |
|
14 | /** |
|
15 | * {@inheritdoc} |
|
16 | */ |
|
17 | public function validate($value, Constraint $constraint) |
|
18 | { |
|
19 | parent::validate($value, $constraint); |
|
20 | ||
21 | if ($value && !IsoCodes\IP::validate($value) && !IsoCodes\IP::validateIPV6($value)) { |
|
22 | $this->createViolation($constraint->message); |
|
23 | } |
|
24 | } |
|
25 | } |
|
26 |
@@ 12-25 (lines=14) @@ | ||
9 | /** |
|
10 | * @author Sullivan Senechal <[email protected]> |
|
11 | */ |
|
12 | final class IsbnValidator extends AbstractIsoCodesConstraintValidator |
|
13 | { |
|
14 | /** |
|
15 | * {@inheritdoc} |
|
16 | */ |
|
17 | public function validate($value, Constraint $constraint) |
|
18 | { |
|
19 | parent::validate($value, $constraint); |
|
20 | ||
21 | if ($value && !IsoCodes\Isbn::validate($value, $constraint->type)) { |
|
22 | $this->createViolation($constraint->message); |
|
23 | } |
|
24 | } |
|
25 | } |
|
26 |
@@ 11-26 (lines=16) @@ | ||
8 | /** |
|
9 | * @author Sullivan Senechal <[email protected]> |
|
10 | */ |
|
11 | class PhoneNumberValidator extends AbstractIsoCodesConstraintValidator |
|
12 | { |
|
13 | /** |
|
14 | * @param mixed $value |
|
15 | * @param PhoneNumber|Constraint $constraint |
|
16 | */ |
|
17 | public function validate($value, Constraint $constraint) |
|
18 | { |
|
19 | parent::validate($value, $constraint); |
|
20 | ||
21 | if ($value && !\IsoCodes\PhoneNumber::validate($value, $constraint->country)) { |
|
22 | // TODO: Manage the "All country" option as for ZipCode. |
|
23 | $this->createViolation($constraint->message); |
|
24 | } |
|
25 | } |
|
26 | } |
|
27 |