from typing import Optional
from sqlmodel import Field, SQLModel
from pydantic import validator
from datetime import datetime
import numpy as np


class Forecast(SQLModel, table=True):

    id: Optional[int] = Field(default=None, primary_key=True)
    user_id: int = Field(foreign_key="app_db.appuser.id")
    epic_id: int = Field(foreign_key="app_db.epic.id")
    days: float
    month: int
    year: int
    created_at: datetime
    updated_at: datetime
    is_locked: bool

    __table_args__ = {"schema": "app_db"}

    @validator("days")
    def valid_days(cls, days_input):
        assert days_input in np.arange(
            0, 24, 0.1
        ), "Work days cannot be greater than 24"
        return days_input

    @validator("year")
    def valid_year(cls, year_input):
        assert year_input >= datetime.now().year
        return year_input

datetime.datetime.now pydantic.validator numpy.arange sqlmodel.Field
[((210, 247), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (215, 247), False, 'from sqlmodel import Field, SQLModel\n'), ((267, 305), 'sqlmodel.Field', 'Field', ([], {'foreign_key': '"""app_db.appuser.id"""'}), "(foreign_key='app_db.appuser.id')\n", (272, 305), False, 'from sqlmodel import Field, SQLModel\n'), ((325, 360), 'sqlmodel.Field', 'Field', ([], {'foreign_key': '"""app_db.epic.id"""'}), "(foreign_key='app_db.epic.id')\n", (330, 360), False, 'from sqlmodel import Field, SQLModel\n'), ((525, 542), 'pydantic.validator', 'validator', (['"""days"""'], {}), "('days')\n", (534, 542), False, 'from pydantic import validator\n'), ((724, 741), 'pydantic.validator', 'validator', (['"""year"""'], {}), "('year')\n", (733, 741), False, 'from pydantic import validator\n'), ((609, 630), 'numpy.arange', 'np.arange', (['(0)', '(24)', '(0.1)'], {}), '(0, 24, 0.1)\n', (618, 630), True, 'import numpy as np\n'), ((808, 822), 'datetime.datetime.now', 'datetime.now', ([], {}), '()\n', (820, 822), False, 'from datetime import datetime\n')]