Question · Python course · Module 6: Async and FastAPI

Type validation

What happens when you pass a string instead of an int to an int field in Pydantic?

Answer options

  • The field is set to None
  • The program crashes
  • The value is ignored
  • Pydantic tries to convert the string to int, and if it can't - returns an error

You can check the correct answer by solving this task in the CodeWorlds game.