mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
43 lines
511 B
Markdown
43 lines
511 B
Markdown
|
---
|
||
|
id: adc652c4-6f67-46e9-a975-8e72b852234c
|
||
|
title: Number Constraints
|
||
|
---
|
||
|
|
||
|
# Syntax
|
||
|
|
||
|
``` php
|
||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||
|
|
||
|
class Person
|
||
|
{
|
||
|
/** @Assert\PositiveOrZero */
|
||
|
protected $siblings;
|
||
|
|
||
|
// ...
|
||
|
}
|
||
|
|
||
|
class Employee
|
||
|
{
|
||
|
/** @Assert\Positive */
|
||
|
protected $income;
|
||
|
|
||
|
// ...
|
||
|
}
|
||
|
|
||
|
class UnderGroundGarage
|
||
|
{
|
||
|
/** @Assert\NegativeOrZero */
|
||
|
protected $level;
|
||
|
|
||
|
// ...
|
||
|
}
|
||
|
|
||
|
class TransferItem
|
||
|
{
|
||
|
/** @Assert\Negative */
|
||
|
protected $withdraw;
|
||
|
|
||
|
// ...
|
||
|
}
|
||
|
```
|