| @@ 30-49 (lines=20) @@ | ||
| 27 | ||
| 28 | $this->validationEngine->validateFieldValue( |
|
| 29 | $parentValidator ?: $this, |
|
| 30 | function() use ($value, $propertyPath, $exceptionMessage) { |
|
| 31 | $uuidValidation = new UuidValidation(); |
|
| 32 | if ($uuidValidation->isUuidValid($value)) { |
|
| 33 | return; |
|
| 34 | } |
|
| 35 | ||
| 36 | if (null === $exceptionMessage) { |
|
| 37 | $exceptionMessage = sprintf( |
|
| 38 | 'Value "%s" is not a valid UUID.', |
|
| 39 | $value |
|
| 40 | ); |
|
| 41 | } |
|
| 42 | ||
| 43 | throw new InvalidArgumentException( |
|
| 44 | $exceptionMessage, |
|
| 45 | 0, |
|
| 46 | $propertyPath, |
|
| 47 | $value |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | ); |
|
| 51 | ||
| 52 | return (string) $value; |
|
| @@ 40-59 (lines=20) @@ | ||
| 37 | { |
|
| 38 | $this->validationEngine->validateFieldValue( |
|
| 39 | $parentValidator ?: $this, |
|
| 40 | function() use ($value, $propertyPath, $exceptionMessage) { |
|
| 41 | $booleanValidation = new BooleanValidation(); |
|
| 42 | if ($booleanValidation->isBooleanValid($value)) { |
|
| 43 | return; |
|
| 44 | } |
|
| 45 | ||
| 46 | if (null === $exceptionMessage) { |
|
| 47 | $exceptionMessage = sprintf( |
|
| 48 | 'Value "%s" is not a boolean.', |
|
| 49 | $value |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | ||
| 53 | throw new InvalidArgumentException( |
|
| 54 | $exceptionMessage, |
|
| 55 | 0, |
|
| 56 | $propertyPath, |
|
| 57 | $value |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | ); |
|
| 61 | ||
| 62 | // Otherwise "false" would return true |
|
| @@ 69-87 (lines=19) @@ | ||
| 66 | $mailMxValidation = new MailMxValidation(); |
|
| 67 | $this->validationEngine->validateFieldValue( |
|
| 68 | $parentValidator ?: $this, |
|
| 69 | function() use ($value, $propertyPath, $exceptionMessage, $mailMxValidation) { |
|
| 70 | if ($mailMxValidation->isEmailFormatValid($value) && $mailMxValidation->isEmailHostValid($value)) { |
|
| 71 | return; |
|
| 72 | } |
|
| 73 | ||
| 74 | if (null === $exceptionMessage) { |
|
| 75 | $exceptionMessage = sprintf( |
|
| 76 | 'Mail "%s" is not valid.', |
|
| 77 | $value |
|
| 78 | ); |
|
| 79 | } |
|
| 80 | ||
| 81 | throw new InvalidArgumentException( |
|
| 82 | $exceptionMessage, |
|
| 83 | 0, |
|
| 84 | $propertyPath, |
|
| 85 | $value |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | ); |
|
| 89 | ||
| 90 | return $value; |
|