Junior — Senior
Creating custom user model field validations
livecode
Task condition
This model is described using Pydantic. You need to add custom validators:
- the name field should contain only Latin letters, without digits and special characters;
- the email field must belong to the gmail.com domain. Use Pydantic's built-in mechanisms (for example, the @validator decorator) for implementation. The original class looks like this:
class User(BaseModel):
id: int
name: str = Field(min_length=3, max_length=32)
email: EmailStr
age: int = Field(ge=0, le=100)
is_active: bool
After adding validators, the model will reject invalid values according to the specified rules.