# generated by datamodel-codegen:
#   filename:  root_model_default_value_non_root.json
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from typing import Annotated, Optional

from pydantic import BaseModel, Field, RootModel


class CountType(RootModel[int]):
    root: Annotated[int, Field(ge=0, le=100)]


class PersonType(BaseModel):
    name: Optional[str] = None


class Model(BaseModel):
    root_model_field: Annotated[
        Optional[CountType],
        Field(default_factory=lambda: CountType.model_validate(CountType(10))),
    ]
    non_root_model_field: Annotated[
        Optional[PersonType],
        Field(default_factory=lambda: PersonType.model_validate({'name': 'John'})),
    ]
    primitive_field: Optional[str] = 'hello'
