* @Assert\NotBlank()
* @Assert\Blank()
* @Assert\NotNull()
* @Assert\Null()
* @Assert\True(message = "The token is invalid")
* @Assert\False(
* message = "You've entered an invalid state."
* )
* @Assert\Type(type="integer", message="The value {{ value }} is not a valid {{ type }}.")
is_
array
bool
callable
float
double
int
integer
long
null
numeric
object
real
resource
scalar
string
ctype_
alnum
alpha
cntrl
digit
graph
lower
print
punct
space
upper
xdigit
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* checkMX = true
* )
* @Assert\Length(
* min = 2,
* max = 50,
* minMessage = "Your first name must be at least {{ limit }} characters long",
* maxMessage = "Your first name cannot be longer than {{ limit }} characters long"
* )
*/
* @Assert\Url()
* @Assert\Regex("/^\w+/")
* @Assert\Regex(
* pattern="/\d/",
* match=false,
* message="Your name cannot contain a number"
* )
* @Assert\Ip
* @Assert\Uuid
* @Assert\Range(
* min = 120,
* max = 180,
* minMessage = "You must be at least {{ limit }}cm tall to enter",
* maxMessage = "You cannot be taller than {{ limit }}cm to enter"
* )
* @Assert\EqualTo(
* value = 20
* )
* @Assert\NotEqualTo(
* value = 15
* )
* @Assert\IdenticalTo(
* value = 20
* )
* @Assert\NotIdenticalTo(
* value = 15
* )
* @Assert\LessThan(
* value = 80
* )
* @Assert\LessThanOrEqual(
* value = 80
* )
* @Assert\GreaterThan(
* value = 18
* )
* @Assert\GreaterThanOrEqual(
* value = 18
* )
* @Assert\Date() ---- YYYY-MM-DD
* @Assert\DateTime() ---- YYYY-MM-DD HH:MM:SS
* @Assert\Time() ---- HH:MM:SS
* @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.")
* @Assert\Choice(callback = "getGenders") ---- should use with below
public static function getGenders()
{
return array('male', 'female');
}
* @Assert\Choice(callback = {"Util", "getGenders"}) ---- with other class method
* @Assert\Collection(
* fields = {
* "personal_email" = @Assert\Email,
* "short_bio" = {
* @Assert\NotBlank(),
* @Assert\Length(
* max = 100,
* maxMessage = "Your short bio is too long!"
* )
* }
* },
* allowMissingFields = true
* )
* @Assert\Collection(
* fields={
* "personal_email" = @Assert\Required({@Assert\ NotBlank, @Assert\Email}),
* "alternate_email" = @Assert\Optional(@Assert\ Email)
* }
* @Assert\Count(
* min = "1",
* max = "5",
* minMessage = "You must specify at least one email",
* maxMessage = "You cannot specify more than {{ limit }} emails"
* )
use Symfony\Bridge\Doctrine\ Validator\Constraints\ UniqueEntity;
/**
* @ORM\Entity
* @UniqueEntity("email")
*/
class Author
{
/**
* @var string $email
*
* @ORM\Column(name="email", type="string", length=255, unique=true)
* @Assert\Email()
*/
protected $email;
}
use Symfony\Bridge\Doctrine\ Validator\Constraints\ UniqueEntity;
/**
* @ORM\Entity
* @UniqueEntity(
* fields={"host", "port"},
* errorPath="port",
* message="This port is already in use on that host."
* )
*/
class Service
{
/**
* @ORM\ManyToOne(targetEntity=" Host")
*/
public $host;
/**
* @ORM\Column(type="integer")
*/
public $port;
}
@Assert\Locale() ---- http://en.wikipedia.org/wiki/ List_of_ISO_639-1_codes
@Assert\Country() ---- http://en.wikipedia.org/wiki/ ISO_3166-1#Current_codes
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"application/pdf", "application/x-pdf"},
* mimeTypesMessage = "Please upload a valid PDF"
* )
* @Assert\Image(
* minWidth = 200,
* maxWidth = 400,
* minHeight = 200,
* maxHeight = 400
* )
* @Assert\Image(
* allowLandscape = false
* allowPortrait = false
* )
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
AMEX
CHINA_UNIONPAY
DINERS
DISCOVER
INSTAPAYMENT
JCB
LASER
MAESTRO
MASTERCARD
VISA
* @Assert\Currency ---- http://en.wikipedia.org/wiki/ ISO_4217
* @Assert\Luhn(message = "Please check your credit card number.")
* @Assert\Iban(message = "This is not a valid International Bank Account Number (IBAN).")
* @Assert\Isbn(
* type = isbn10, ---- (or isbn13 or null)
* message: This value is not valid.
* )
* @Assert\Issn
/**
* @Assert\All({
* @Assert\NotBlank,
* @Assert\Length(min = 5)
* })
*/
protected $favoriteColors = array();
class Author
{
/**
* @Assert\Valid
*/
protected $address; (Object!!!!)
}
Comments
Post a Comment