mirror of
https://github.com/alrayyes/wiki.git
synced 2025-07-24 09:49:34 +00:00
Quartz sync: May 6, 2024, 10:40 PM
This commit is contained in:
parent
aee9145691
commit
4ef8371441
635 changed files with 22281 additions and 6 deletions
33
content/20201111103048-symfony_divisibleby_constraint.md
Normal file
33
content/20201111103048-symfony_divisibleby_constraint.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
id: 5cc7016f-2142-47c3-b256-d295a58339a7
|
||||
title: Symfony DivisibleBy Constraint
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
Introduced in [Symfony 4.2](20201111101706-symfony_4_2), `DivisibleBy`
|
||||
enforces specific increments on a number.
|
||||
|
||||
# Syntax
|
||||
|
||||
``` php
|
||||
// src/Entity/Item.php
|
||||
namespace App\Entity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class Item
|
||||
{
|
||||
/**
|
||||
* @Assert\DivisibleBy(0.25)
|
||||
*/
|
||||
protected $weight;
|
||||
|
||||
/**
|
||||
* @Assert\DivisibleBy(
|
||||
* value = 5,
|
||||
* message = "This item requires to be stocked in multiples of 5 units."
|
||||
* )
|
||||
*/
|
||||
protected $quantity;
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue