You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
api/app/models/pin.py

19 lines
640 B

from typing import Optional, List
from pydantic import BaseModel, Field, validator
from datetime import datetime
class Pin(BaseModel):
id: Optional[str]
title: str = Field(..., min_length=3)
description: str = Field(..., min_length=3)
location: list = Field(..., min_items=2)
complete_address: str = Field(..., min_length=3)
files: Optional[List[str]] = [] # Liste des IDs d'images
user_id: str
date: Optional[datetime] = None
@validator('location')
def validate_location(cls, v):
if not v or len(v) == 0:
raise ValueError('La location ne peut pas être vide')
return v