markwilson/symfony2-validator-native-filter

This package is abandoned and no longer maintained. No replacement package was suggested.

Native PHP filter constraint for Symfony2 validator component

dev-master 2014-01-08 16:26 UTC

This package is not auto-updated.

Last update: 2021-01-23 09:25:00 UTC


README

Note: currently only works for validator component 2.2.x

Native PHP filter constraint for Symfony2 validator component.

Install

Add markwilson/symfony2-validator-native-filter to composer.json requires.

Usage

NativeFilter requires a filter option which must be one of the FILTER_ prefixed constants.

e.g.

use MarkWilson\Validator\Constraints\NativeFilter;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Validation;

$constraint = new NativeFilter(
    array(
        'filter' => FILTER_VALIDATE_FLOAT
    )
);

$validator = Validation::createValidator();
$validator->validateValue($value, $constraint);