Skip to content

Instantly share code, notes, and snippets.

@tarlepp
Last active May 3, 2018 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tarlepp/d89d32e155cc26a1a9926737af633066 to your computer and use it in GitHub Desktop.
Save tarlepp/d89d32e155cc26a1a9926737af633066 to your computer and use it in GitHub Desktop.
public function validate($value, Constraint $constraint): void
{
try {
if ($someService->checkValue($value)) {
$this->context
->buildViolation($constraint->message)
->addViolation();
}
} catch (YourSpecialException $exception) {
// Silently ignore this one
} catch (\Exception $exception) {
$this->context
->buildViolation($exception->getMessage())
->addViolation();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment