Skip to content

Commit

Permalink
Validation des données
Browse files Browse the repository at this point in the history
  • Loading branch information
KoukiFactori committed Feb 8, 2023
1 parent 8572600 commit 64e1d88
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Entity/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\RatingRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

#[ORM\Entity(repositoryClass: RatingRepository::class)]
#[UniqueEntity(fields: ['user', 'bookmark'])]
#[ApiResource]
class Rating
{
Expand All @@ -21,6 +24,7 @@ class Rating
private ?User $user = null;

#[ORM\Column(type: Types::SMALLINT)]
#[Assert\Range(min: 0, max: 10, notInRangeMessage: 'Rating value must be between 0 and 10')]
private ?int $value = null;

#[ORM\ManyToOne(inversedBy: 'ratings')]
Expand Down

0 comments on commit 64e1d88

Please sign in to comment.