# generated by datamodel-codegen:
#   filename:  field_validators.json

from __future__ import annotations

from typing import Annotated, Any

from myapp.validators import validate_email, validate_name
from pydantic import BaseModel, EmailStr, Field, ValidationInfo, field_validator


class User(BaseModel):
    name: str
    email: EmailStr
    age: Annotated[int | None, Field(ge=0)] = None

    @field_validator('name', mode='before')
    @classmethod
    def validate_name_validator(cls, v: Any, info: ValidationInfo) -> Any:
        return validate_name(v, info)

    @field_validator('email', mode='after')
    @classmethod
    def validate_email_validator(cls, v: Any, info: ValidationInfo) -> Any:
        return validate_email(v, info)
