1. Learn
  2. /
  3. Courses
  4. /
  5. Deploying AI into Production with FastAPI

Connected

Exercise

Adding custom validators

Mode360 Solutions is the organization behind the comment moderation system, and you're given a task to create a validation service for all employees. The system should be able to validate input details (username, email and age) such that only employees with an official email address can register.

You need to define a Pydantic User model using @field_validator decorator on email to check if the entered email ends with @mode360.com

These validators enhance security and system integration.

Instructions

100 XP
  • Add the Pydantic decorator to create a custom validator on the email field.
  • Use the string endswith method to check if the email address ends with the @mode360.com domain.