Error: cannot import name 'field_validator' from 'pydantic'

192 views Asked by At

I'm working through the new version (v1.6.0) of the course and am running into an issue when attempting to import 'field_validator' from 'pydantic'. I'm using v2.6.3 of pydantic and receiving the following error when attempting to bring up the web server:

ImportError: cannot import name 'field_validator' from 'pydantic'

1

There are 1 answers

0
Talha Tayyab On

From the document I can see:

https://docs.pydantic.dev/latest/concepts/validators/#dataclass-validators

field_validator is present in all the versions >=2 (2.0,2.1,2.2,2.3,2.4,2.5,2.6)

from pydantic import field_validator
from pydantic.dataclasses import dataclass

However, it is not present in version 1.10