0

I have a model, Users

class Users(ormar.Model):
    class Meta(BaseMeta):
        tablename = "users"

    id: int = ormar.Integer(primary_key=True)
    first_name: str = ormar.String(max_length=255)
    middle_name: Union[str, None] = ormar.String(nullable=True, max_length=255)
    last_name: Union[str, None] = ormar.String(nullable=True, max_length=255)

i wish to add a url profile_image and I want the URL validation to be done at database level instead of API level

Is it possbile to do the same? without switching to SQLAlchemy?

I have tried lookup the docs, but could not find anything helpful.

код е
  • 196
  • 2
  • 11
  • If you want the validation to be done on the database level, support for that will depend on which database you use, so which are you using? Otherwise, if you're fine with doing the validation on the API level, you could use the [`overwrite_pydantic_type`](https://collerek.github.io/ormar/fields/common-parameters/#overwrite_pydantic_type) feature to use pydantic's [`HttpUrl`](https://docs.pydantic.dev/usage/types/#urls) type for validation. – M.O. Feb 12 '23 at 19:47

0 Answers0