Use constr instead str:
constr
str
from ninja import Schema from pydantic import constr class TestSchema(Schema): name1: constr(min_length=6, max_length=6) name2: constr(max_length=6) name3: constr(min_length=6)