Skip to main content

appsync-scalars for Python

Checks whether a value is a valid AWS AppSync AWSDate, AWSTime, AWSDateTime or AWSTimestamp, using rules recorded from a live AppSync API. Use it to catch a bad value before AppSync rejects the whole request.

Also available for JavaScript, Rust and Go.

Install

pip install appsync-scalars

It needs Python 3.10 or later and has no dependencies. Prebuilt wheels cover Linux (x64 and arm64, glibc 2.17 or later), macOS (Apple silicon and Intel) and Windows (x64). Anywhere else, including Alpine Linux, pip builds from source, which needs Rust.

Usage

from appsync_scalars import is_aws_date, validate_aws_datetime

is_aws_date("1970-01-01+05:30")  # True
is_aws_date("2021-02-29")  # False

try:
    validate_aws_datetime("2021-01-11T12:30:24")
except ValueError as error:
    print(error)  # invalid AWSDateTime: time zone offset is required

Each scalar has two functions. The is_ function returns a bool, and the validate_ function returns None or raises ValueError with the reason.

Scalar Takes Returns a bool Raises ValueError
AWSDate str is_aws_date validate_aws_date
AWSTime str is_aws_time validate_aws_time
AWSDateTime str is_aws_datetime validate_aws_datetime
AWSTimestamp int is_aws_timestamp validate_aws_timestamp

Passing a non-string to a text scalar's functions raises TypeError. The AWSTimestamp functions treat anything but an int as invalid, including True and "123".

Pydantic

Field types for Pydantic v2 come with an optional extra:

pip install "appsync-scalars[pydantic]"
from pydantic import BaseModel, ValidationError
from appsync_scalars.pydantic import AWSDate, AWSDateTime, AWSTimestamp

class Event(BaseModel):
    day: AWSDate
    starts_at: AWSDateTime
    created: AWSTimestamp

Event(day="2021-01-11", starts_at="2021-01-11T12:30:24Z", created=1610368224)

try:
    Event(day="2021-02-29", starts_at="2021-01-11T12:30:24Z", created=1610368224)
except ValidationError as error:
    print(error.errors()[0]["type"])  # aws_date

AWSDate, AWSTime, AWSDateTime and AWSTimestamp behave like this:

  • Values stay as given. A field holds the exact str or int you passed, not a datetime, because datetime can't hold negative years and keeps only microseconds.
  • Nothing is converted. Fields are strict, so "123" isn't accepted as an AWSTimestamp, and a datetime isn't accepted as an AWSDateTime.
  • Invalid values have stable error types. They are aws_date, aws_time, aws_datetime and aws_timestamp, and the message gives the reason. A value of the wrong type gets Pydantic's own string_type or int_type instead.
  • JSON Schema shows the type. Fields use a format of aws-date, aws-time, aws-datetime or aws-timestamp.

What counts as valid

Scalar Valid examples
AWSDate 1970-01-01, 1970-01-01Z, 1970-01-01+05:30, -2017-05-01
AWSTime 12:30, 12:30:24.500, 12:30:24-07:00
AWSDateTime 2021-01-11T12:30Z, 1970-01-01T12:00:00.123456789+05:30 (the offset is required)
AWSTimestamp 1610368224, -123123 (whole seconds since 1970)

AppSync accepts and rejects some values its descriptions don't mention, and this library follows AppSync. See what AppSync accepts.

License

MIT

Metadata

Release files for appsync-scalars 0.1.3

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

Source distribution (sdist)

Source distribution for appsync-scalars 0.1.3
File Size Uploaded Provenance Actions
appsync_scalars-0.1.3.tar.gz 42.1 kB With provenance Details for appsync_scalars-0.1.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for appsync-scalars 0.1.3
File Actions
appsync_scalars-0.1.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for appsync_scalars-0.1.3-cp310-abi3-win_amd64.whl
appsync_scalars-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for appsync_scalars-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
appsync_scalars-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for appsync_scalars-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
appsync_scalars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for appsync_scalars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
appsync_scalars-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for appsync_scalars-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 962.5 kB

Release files / appsync_scalars-0.1.3.tar.gz

Download URL appsync_scalars-0.1.3.tar.gz
Size 42.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3021f3e815f5e1ac1fb913ba1f7ef3e4be96c8c300876947b1bb15bcfa7c3dc8
BLAKE2b-256 checksum
How to use checksums
626c052d0b7efc1478113a9f650797b453ea8c9198406fa74c468e2350f08adb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / appsync_scalars-0.1.3-cp310-abi3-win_amd64.whl

Download URL appsync_scalars-0.1.3-cp310-abi3-win_amd64.whl
Size 108.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2658e2383649cacbbca18f618d447c8c97dafd79a710c4bff68cdf4289dd318f
BLAKE2b-256 checksum
How to use checksums
b5f0d354fecee3dd5c74e3ac7f0a57eea1df4477e663b44bcd5c68176b67bcfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / appsync_scalars-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL appsync_scalars-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 221.5 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
760a1cd47126cfe255892bb76e4fd4487a187060f0096a3f6ecc95244a189b61
BLAKE2b-256 checksum
How to use checksums
8d71b8c5cb56f75e5c0ef7f3cb6ac00b05dc9e815898ea5773376a8c387c6db0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / appsync_scalars-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL appsync_scalars-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 215.9 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
c0cb84c58871de573b80462628689820698002cfbc9dfd3aa0a4370bfb48e825
BLAKE2b-256 checksum
How to use checksums
860f1a4e209945e1b9b0d37da0009af372f433ab44b7a02e18c65c4ee6a62f89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / appsync_scalars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl

Download URL appsync_scalars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
Size 185.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b85bc844334b618b94050ce712589e7f811ff84949393b85f488212bec42cb4e
BLAKE2b-256 checksum
How to use checksums
fabcce2f43de6e443f7c84cc95decf43ba1bd074df1280d1f5757fc6b8a7b7c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / appsync_scalars-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl

Download URL appsync_scalars-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl
Size 188.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ba7546252ebec705dc3bb2e80f4b54399d1cb32889c331c5485b14de3fab9b73
BLAKE2b-256 checksum
How to use checksums
73f722d7f068af6862f56952eccecf5fae58fb18706c85fead9255c02729af16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for appsync-scalars 0.1.3

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for appsync_scalars-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

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