PHP code example of braincrafted / validation-bundle
1. Go to this page and download the library: Download braincrafted/validation-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
braincrafted / validation-bundle example snippets
// 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;
// ...
}
// 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')));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.