refactor: update rating validation logic — enforce minimum rating value
All checks were successful
CI / Check / Test (push) Successful in 1h5m56s

This commit is contained in:
2026-07-10 13:22:21 +02:00
parent fa881c3fd1
commit 6bf4ffc4ab
4 changed files with 54 additions and 4 deletions

View File

@@ -86,10 +86,11 @@ pub fn format_watched_at(dt: &chrono::NaiveDateTime) -> String {
pub struct Rating(u8);
impl Rating {
const MIN: u8 = 1;
const MAX: u8 = 5;
pub fn new(value: u8) -> Result<Self, DomainError> {
if value <= Self::MAX {
if (Self::MIN..=Self::MAX).contains(&value) {
Ok(Self(value))
} else {
Err(DomainError::InvalidRating {