Skip to content

Make default validation cheap, make full validation optional #10

@sneakers-the-rat

Description

@sneakers-the-rat

When just opening a file, usually we don't care too much about all the validity checks, that's mostly for us when we're checking if something's wrong. the validations end up taking a long freaking time for very large torrents because there are several big iterations in there, so we should

  • change the general behavior of instantiating the Torrent model to exclude all but the necessary validations
  • make a decorator for the validators that allows us to declare some validation types/scopes/profiles and etc, like
@field_validator("whatever", mode="after")
@validation_scope("pieces", "something-else")
def some_validation_function(...): ...

So that we can then use the context like

Torrent.model_validate(data, context={"tm_validation": ["pieces"]})
# or
Torrent.model_validate(data, context={"tm_validation": ["all"]})
  • make a torrent_validate method that is a shortcut to that
  • accept validation modes in read()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions