mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-21 19:16:23 +00:00
627 B
627 B
date | id | title |
---|---|---|
2020-11-11 | 5cc7016f-2142-47c3-b256-d295a58339a7 | Symfony DivisibleBy Constraint |
Introduction
Introduced in Symfony 4.2, DivisibleBy
enforces specific increments on a number.
Syntax
// 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;
}