2017 © Pedro Peláez
 

symfony-bundle validation-bundle

Validators for Symfony2

image

braincrafted/validation-bundle

Validators for Symfony2

  • Thursday, January 23, 2014
  • by florianeckerstorfer
  • Repository
  • 1 Watchers
  • 5 Stars
  • 107 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

BraincraftedValidationBundle

Handcrafted in Vienna by Florian Eckerstorfer., (*1)

Build Status Scrutinizer Quality Score Code Coverage, (*2)

Installation

BraincraftedValidationBundle can be installed using Commposer., (*3)

{
    "require": {
        "braincrafted/validation-bundle": "@stable"
    }
}

Replace @stable with the latest stable release., (*4)

Usage

If BraincraftedValidationBundle has been added to the project, its validators can be used just like every other Symfony2 validator., (*5)

Using with YAML

# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\DemoBundle\Entity\AcmeEntity:
    properties:
        name:
            - NotBlank: ~
            - Braincrafted\Bundle\ValidationBundle\Validator\Constraints\Enum:
                allowedValues: ["ACTIVE", "PAUSED", "DELETED"]

Using with Annotations

// src/Acme/DemoBundle/Entity/AcmeEntity.php
use Symfony\Component\Validator\Constraints as Assert;
use Braincrafted\Bundle\ValidationBundle\Validator\Constraints as BraincraftedAssert;

class AcmeEntity
{
    // ...
    /**
     * @Assert\NotBlank
     * @BraincraftedAssert\Enum(allowedValues={"ACTIVE", "PAUSED, "DELETED""})
     */
    protected $status;
    // ...
}

Using with XML



<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

    <class name="Acme\DemoBundle\Entity\AcmeEntity">
        <property name="name">
            <constraint name="NotBlank" />
            <constraint name="Braincrafted\Bundle\ValidationBundle\Validator\Constraints\Enum">
                <option name="allowedValues">
                    <value>ACTIVE</value>
                    <value>PAUSED</value>
                    <value>DELETED</value>
                </option>
            </constraint>
        </property>
    </class>
</constraint-mapping>

Using with PHP

// src/Acme/DemoBundle/Entity/AcmeEntity.php
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Braincrafted\Bundle\ValidationBundle\Validator\Constraints\Enum;

class AcmeEntity
{
    public $name;

    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('status', new NotBlank());
        $metadata->addPropertyConstraint('status', new Enum(array('ACTIVE', 'PAUSED', 'DELETED')));
    }
}

Available Validators

Enum

  • Options:
    • string message
    • array allowedValues

Changelog

Version 0.3 (21 November 2013)

  • #6: Fixed error message [by Tobur]

Version 0.2 (17 November 2013)

  • Changed namespace to Braincrafted\Bundle\ValidationBundle

License

The MIT License (MIT)

Copyright (c) 2012-2013 Florian Eckerstorfer, (*6)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*7)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*8)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*9)

Bitdeli Badge, (*10)

The Versions

23/01 2014

dev-master

9999999-dev

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

validation

21/12 2013

0.3.x-dev

0.3.9999999.9999999-dev

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

validation

21/12 2013

v0.3

0.3.0.0

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

validation

17/11 2013

0.2.x-dev

0.2.9999999.9999999-dev

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

validation

17/11 2013

v0.2

0.2.0.0

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

validation

08/07 2013

0.1.x-dev

0.1.9999999.9999999-dev

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

validation

08/07 2013

v0.0.1

0.0.1.0

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

validation

08/07 2013

v0.1

0.1.0.0

Validators for Symfony2

  Sources   Download

MIT

The Requires

 

validation