works with plain silex-php
- Register validators
- php >=5.3
- symfony/validator >=2.3
- doctrine/annotations ~1.0
- symfony/config >=2.3
- symfony/config >=2.3
- symfony/yaml >=2.3
Through Composer as saxulum/saxulum-validator-provider.
use Silex\Provider\ValidatorServiceProvider;
use Saxulum\Validator\Provider\SaxulumValidatorProvider;
$container->register(new ValidatorServiceProvider());
$container->register(new SaxulumValidatorProvider());
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
Register xml files.
$container['validator.loader.xml.files'] = $container->extend('validator.loader.xml.files', function ($files) {
$files[] = __DIR__ . '/../../Fixtures/test.xml';
return $files;
});
Register yml files.
$container['validator.loader.yaml.files'] = $container->extend('validator.loader.yaml.files', function ($files) {
$files[] = __DIR__ . '/../../Fixtures/test.yaml';
return $files;
});
$container['validator']->validate($object);