Skip to main content

pecan-notario

JSON validation for Pecan with Notario (http://notario.cafepais.com).

In its simplest form, you need to define a schema and decorate the controller method, like:

schema = ('foo', True)

@expose()
@validate(schema)
def some_controller(self, **kw):
    return dict()

The above controller method, using a Notario schema, will require a foo key and a True value otherwise it will (by default) set the HTTP response to a 400 (invalid request) and add the validation error to request.pecan['schema'].errors.

Using a handler

If more granular control is needed when dealing with an error condition, a handler can be passed in to the decorator to deal with errors explicitly.

@expose()
@validate(some_schema, '/some/handler')
def some_controller(self, **kw):
    return dict()

In this situation ‘/some/handler’ would be a controller method that can deal directly with the error that was slapped onto the request object (on request.validation_error).

Notario exceptions will include a reason attribute that will contain the specific error message that was raised if a custom validator failed with an error message. In this case, a handler would access this Notario exception attribute like:

request.validation_error.reason

Metadata

Release files for pecan-notario 0.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 pecan-notario 0.0.1
File Size Uploaded Provenance Actions
pecan-notario-0.0.1.tar.gz 3.0 kB Without provenance Details for pecan-notario-0.0.1.tar.gz

Release files / pecan-notario-0.0.1.tar.gz

Download URL pecan-notario-0.0.1.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4c9d62cd0dd6f9c60d653f85a95c91dd700e9e8f95b33c4d6abb0904a3ba02a4
BLAKE2b-256 checksum
How to use checksums
d32f212846499ea94da7ba0161047dd342f703a564260437eb7f3a864c7fc98e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pecan-notario 0.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