2017 © Pedro Peláez
 

library search-symfony-validator

Symfony validator extension for RollerworksSearch

image

rollerworks/search-symfony-validator

Symfony validator extension for RollerworksSearch

  • Monday, July 23, 2018
  • by sstok
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,778 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 16 Versions
  • 27 % Grown

The README.md

RollerworksSearch Symfony Validator

Build Status, (*1)

The RollerworksSearch Symfony Validator facilitates the validating of input values using the Symfony Validator component., (*2)

Note:, (*3)

This validation is meant to be used for business rules like a minimum/maximum value range or disallowing specific patterns. The data transformers already ensure the value is properly transformed., (*4)

Installation

To install this extension, add the rollerworks/search-symfony-validator package in your composer.json and update your dependencies., (*5)

$ composer require rollerworks/search-symfony-validator

Next you need to enable the Rollerworks\Component\Search\Extension\Symfony\Validator\ValidatorExtension in the SearchFactoryBuilder and pass the Input Validator to your Input Processor., (*6)

use Rollerworks\Component\Search\Searches;
use Rollerworks\Component\Search\Extension\Validator\ValidatorExtension;
use Rollerworks\Component\Search\Extension\Validator\InputValidator;
use Rollerworks\Component\Search\Input\StringQueryInput;
use Symfony\Component\Validator\Validation;

$searchFactory = Searches::createSearchFactoryBuilder();
    ->addExtension(new ValidatorExtension())
    // ...

    ->getSearchFactory();

$validatorBuilder = Validation::createValidatorBuilder();
$validator = $validatorBuilder->getValidator();

$inputProcessor = new StringQueryInput(new InputValidator($validator));

That's it, you can now use the Validator. But note only search fields with constraints set will be actually validated by the validator., (*7)

Setting validation constraints

Before you continue make sure you have a good understanding of what Constraints are and how they are to be used. See Symfony Validator component for more information., (*8)

You can configure the constraint on a per-field basis when building your FieldSet:, (*9)

use Symfony\Component\Validator\Constraints as Assert;
use Rollerworks\Component\Search\Extension\Core\Type\IntegerType;

// ..

$fieldSetBuilder = $searchFactory->createFieldSetBuilder()
$fieldSetBuilder->add('id', IntegerType::class, ['constraints' => new Assert\Range(['min' => 5])]);

Or when your (custom) type always needs these specific constraints make the constraints part of the field type using the configureOptions method of the field type. Using:, (*10)

public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults(
        [
            'constraints' => new Assert\Length(array('min' => 101)),
        ]
    );
}

Symfony framework integration

Note: The Symfony integration bundle for RollerworksSearch already enables the Symfony validator service. You don't need to do anything but configure your field's constraints., (*11)

License

The source of this package is subject to the MIT license that is bundled with this source code in the file LICENSE., (*12)

If you'd like to contribute to this project, please see the [RollerworksSearch contributing guide][3]., (*13)

The Versions

23/07 2018

dev-master

9999999-dev

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

23/07 2018

v2.0.0-ALPHA13

2.0.0.0-alpha13

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

23/07 2018

v2.0.0-ALPHA14

2.0.0.0-alpha14

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/12 2017

v2.0.0-ALPHA6

2.0.0.0-alpha6

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/12 2017

v2.0.0-ALPHA8

2.0.0.0-alpha8

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/12 2017

v2.0.0-ALPHA9

2.0.0.0-alpha9

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/12 2017

v2.0.0-ALPHA10

2.0.0.0-alpha10

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/12 2017

v2.0.0-ALPHA11

2.0.0.0-alpha11

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/12 2017

v2.0.0-ALPHA12

2.0.0.0-alpha12

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

19/10 2017

v2.0.0-ALPHA2

2.0.0.0-alpha2

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

19/10 2017

dev-legacy

dev-legacy

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

18/08 2017

v2.0.0-ALPHA1

2.0.0.0-alpha1

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

13/02 2017

1.x-dev

1.9999999.9999999.9999999-dev

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

05/12 2015

v1.0.1

1.0.1.0

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

16/09 2015

v1.0.0

1.0.0.0

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks

15/03 2015

v1.0.0-beta1

1.0.0.0-beta1

Symfony validator extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

validation search symfony rollerworks