2017 © Pedro Peláez
 

library predaddy-symfony-validator

Symfony validation component for predaddy

image

predaddy/predaddy-symfony-validator

Symfony validation component for predaddy

  • Sunday, November 9, 2014
  • by szjani
  • Repository
  • 2 Watchers
  • 4 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 2 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

predaddy-symfony-validator

Latest Stable Version Scrutinizer Code Quality SensioLabsInsight Gitter chat, (*1)

master
Build Status
Coverage Status

The ValidationInterceptor provided by this library helps validating messages posted to predaddy MessageBus. It is based on Symfony Validator component., (*2)

Usage

$bus = SimpleMessageBus::builder()
    ->withInterceptors([new ValidatorInterceptor()])
    ->build();
class CreateUser
{
    /**
     * @Assert\Length(min = 3)
     * @Assert\NotBlank
     */
    private $name;

    /**
     * @Assert\Email
     * @Assert\NotBlank
     */
    private $email;

    public function __construct($name, $email)
    {
        $this->name = $name;
        $this->email = $email;
    }

    /**
     * @Assert\True(message = "The user should have a Google Mail account")
     */
    public function isGmailUser()
    {
        return false !== strpos($this->email, '@gmail.com');
    }

    public function __toString()
    {
        return Objects::toStringHelper($this)
            ->add('name', $this->name)
            ->add('email', $this->email)
            ->toString();
    }
}
try {
    $bus->post(new CreateUser('John Doe', 'john@example.com'));
} catch (ValidationException $e) {
    $e->getViolationList();
}

If you use annotation constraints, do not forget to register its namespace:, (*3)

AnnotationRegistry::registerAutoloadNamespace('Symfony\Component\Validator\Constraint', 'path/to/symfony/library/validator');

The Versions

09/11 2014

dev-master

9999999-dev

Symfony validation component for predaddy

  Sources   Download

MIT

The Requires

 

The Development Requires

validation symfony predaddy