2018-02-05 18:39:58 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the NelmioApiDocBundle package.
|
|
|
|
*
|
|
|
|
* (c) Nelmio
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
|
|
|
|
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
|
|
|
|
class SymfonyConstraints
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\NotBlank()
|
|
|
|
*/
|
|
|
|
private $propertyNotBlank;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\NotNull()
|
|
|
|
*/
|
|
|
|
private $propertyNotNull;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\Length(min="0", max="50")
|
|
|
|
*/
|
2018-08-30 00:32:11 +02:00
|
|
|
private $propertyAssertLength;
|
2018-02-05 18:39:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\Regex(pattern="/[a-z]{2}/")
|
|
|
|
*/
|
|
|
|
private $propertyRegex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\Count(min="0", max="10")
|
|
|
|
*/
|
|
|
|
private $propertyCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\Choice(choices={"choice1", "choice2"})
|
|
|
|
*/
|
|
|
|
private $propertyChoice;
|
|
|
|
|
2018-05-20 15:59:52 +02:00
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\Choice(callback={SymfonyConstraints::class,"fetchAllowedChoices"})
|
|
|
|
*/
|
|
|
|
private $propertyChoiceWithCallback;
|
|
|
|
|
2018-02-05 18:39:58 +01:00
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @Assert\Expression(
|
|
|
|
* "this.getCategory() in ['php', 'symfony'] or !this.isTechnicalPost()",
|
|
|
|
* message="If this is a tech post, the category should be either php or symfony!"
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
private $propertyExpression;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $propertyNotBlank
|
|
|
|
*/
|
|
|
|
public function setPropertyNotBlank(int $propertyNotBlank): void
|
|
|
|
{
|
|
|
|
$this->propertyNotBlank = $propertyNotBlank;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $propertyNotNull
|
|
|
|
*/
|
|
|
|
public function setPropertyNotNull(int $propertyNotNull): void
|
|
|
|
{
|
|
|
|
$this->propertyNotNull = $propertyNotNull;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-30 00:32:11 +02:00
|
|
|
* @param int $propertyAssertLength
|
2018-02-05 18:39:58 +01:00
|
|
|
*/
|
2018-08-30 00:32:11 +02:00
|
|
|
public function setPropertyAssertLength(int $propertyAssertLength): void
|
2018-02-05 18:39:58 +01:00
|
|
|
{
|
2018-08-30 00:32:11 +02:00
|
|
|
$this->propertyAssertLength = $propertyAssertLength;
|
2018-02-05 18:39:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $propertyRegex
|
|
|
|
*/
|
|
|
|
public function setPropertyRegex(int $propertyRegex): void
|
|
|
|
{
|
|
|
|
$this->propertyRegex = $propertyRegex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $propertyCount
|
|
|
|
*/
|
|
|
|
public function setPropertyCount(int $propertyCount): void
|
|
|
|
{
|
|
|
|
$this->propertyCount = $propertyCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $propertyChoice
|
|
|
|
*/
|
|
|
|
public function setPropertyChoice(int $propertyChoice): void
|
|
|
|
{
|
|
|
|
$this->propertyChoice = $propertyChoice;
|
|
|
|
}
|
|
|
|
|
2018-05-20 15:59:52 +02:00
|
|
|
/**
|
|
|
|
* @param int $propertyChoiceWithCallback
|
|
|
|
*/
|
|
|
|
public function setPropertyChoiceWithCallback(int $propertyChoiceWithCallback): void
|
|
|
|
{
|
|
|
|
$this->propertyChoiceWithCallback = $propertyChoiceWithCallback;
|
|
|
|
}
|
|
|
|
|
2018-02-05 18:39:58 +01:00
|
|
|
/**
|
|
|
|
* @param int $propertyExpression
|
|
|
|
*/
|
|
|
|
public function setPropertyExpression(int $propertyExpression): void
|
|
|
|
{
|
|
|
|
$this->propertyExpression = $propertyExpression;
|
|
|
|
}
|
2018-05-20 15:59:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function fetchAllowedChoices()
|
|
|
|
{
|
|
|
|
return ['choice1', 'choice2'];
|
|
|
|
}
|
2018-02-05 18:39:58 +01:00
|
|
|
}
|