Skip to main content

Business-Validator

ErrorSchema

Use business_validator.ErrorSchema if you don't know which format you're gonna use.

Quick Start

DTO

class CommentDto(BaseModel):
    comment: str
    post_id: int
    owner_id: int

Add error source (error context)

class Source(BaseModel):
    local: str

DTO Validator

@dataclasses.dataclass()
class CommentValidator(Validator[ErrorSchema[Source]]):
    dto: CommentDto

    @validate
    async def test1(self):
        post_ids = list(range(1, 10))

        if self.dto.post_id not in post_ids:
            self.context.add_error(
                ErrorSchema(
                    code=ErrorCodeEnum.not_found.value,
                    message="Id doen't not exists",
                    detail=f"Post with id={self.dto.post_id} not found",
                    source=Source(
                        local="data/post_id",
                    ),
                )
            )

    @validate
    async def test2(self):
        owner_ids = list(range(1, 10))

        if self.dto.owner_id not in owner_ids:
            self.context.add_error(
                ErrorSchema(
                    code=ErrorCodeEnum.not_found.value,
                    message="Id doen't not exists",
                    detail=f"User with id={self.dto.post_id} not found",
                    source=Source(
                        local="data/owner_id",
                    ),
                )
            )

Use

async def function():
    validator = CommentValidator(...)
    errors = await validator.errors()
    # or
    await validator.validate() # raise ValidationError

Metadata

Release files for business-validator 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for business-validator 2.0.1
File Size Uploaded Provenance Actions
business_validator-2.0.1.tar.gz 5.4 kB Without provenance Details for business_validator-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for business-validator 2.0.1
File Interpreter ABI Platform Actions
business_validator-2.0.1-py3-none-any.whl Python 3 none any Details for business_validator-2.0.1-py3-none-any.whl

Total release size: 12.5 kB

Release files / business_validator-2.0.1.tar.gz

Download URL business_validator-2.0.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
272bde76d439023226d8af299354eab3a4278f1beecc7582e84e4b109a043c7f
BLAKE2b-256 checksum
How to use checksums
73d5b324d56cb56c6e0e406261fdfb3876b5711fcdafaf9dc03ad80526ab2ddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / business_validator-2.0.1-py3-none-any.whl

Download URL business_validator-2.0.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bdbf06325ee8ee21f3e0e91de24681c4544d420a451c5f1d3d62b2f63594063
BLAKE2b-256 checksum
How to use checksums
80503dedd5f270a530d956f51db628dd73cd2710bcf7c5907808523153906d7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for business-validator 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page