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". An int subclass, such as an IntEnum, is judged by its integer value.

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. The one exception is Pydantic's validate_strings, which is meant for query strings where every value is text, so it still turns "1_000" into 1000 before the check.
  • 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.4

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.4
File Size Uploaded Provenance Actions
appsync_scalars-0.1.4.tar.gz 42.7 kB With provenance Details for appsync_scalars-0.1.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for appsync-scalars 0.1.4
File Actions
appsync_scalars-0.1.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for appsync_scalars-0.1.4-cp310-abi3-win_amd64.whl
appsync_scalars-0.1.4-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.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
appsync_scalars-0.1.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for appsync_scalars-0.1.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
appsync_scalars-0.1.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for appsync_scalars-0.1.4-cp310-abi3-macosx_11_0_arm64.whl
appsync_scalars-0.1.4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for appsync_scalars-0.1.4-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 962.8 kB

Release files / appsync_scalars-0.1.4.tar.gz

Download URL appsync_scalars-0.1.4.tar.gz
Size 42.7 kB
Tags Source
SHA-256 checksum
How to use checksums
63a8946ee29590022c3341c70aa758a94be1ae424f19150f6af39c1ff1a684ba
BLAKE2b-256 checksum
How to use checksums
c21b03fa041e09f986bef470906a381c6ec8bcbacef71df81df86a6c95daf799
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.4-cp310-abi3-win_amd64.whl

Download URL appsync_scalars-0.1.4-cp310-abi3-win_amd64.whl
Size 108.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3b4b78f572b73f80dac7417543867a02456d093213c548252515d1617d112a94
BLAKE2b-256 checksum
How to use checksums
0de1a934f853a6a0fde351012cb16ff94c7d3838f52c042c007c4828d9b41ed5
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.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL appsync_scalars-0.1.4-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
166a11e9be46f5bdf4840275f0185b09fe37a07b65bf5ce32060e627f6e968ad
BLAKE2b-256 checksum
How to use checksums
a8afc892d55b44ad257f0eca1f7de196e3bf98fd19b71f9b31046a4b5ccd1e33
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.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL appsync_scalars-0.1.4-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
71499a66aea8292f2a2d6532745229981f76e1d9d3710fd3455b91cecd07f940
BLAKE2b-256 checksum
How to use checksums
400953dd08b9d536e81417f50aa0fa232227e600beb586e7cb3da6a6d32e176b
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.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL appsync_scalars-0.1.4-cp310-abi3-macosx_11_0_arm64.whl
Size 185.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a25f2c445df1c287a717b07907fc27645f3f7c50d7beb49abe8e47033cad8f5e
BLAKE2b-256 checksum
How to use checksums
ec8ce86441cd396e23771f67d43beeb20ca3a8e03ce08b23ff736dded923f021
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.4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL appsync_scalars-0.1.4-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
dc770db979f709045b2ebef6a6aeee01b9f0d12507348443aea455b9c8e7aed8
BLAKE2b-256 checksum
How to use checksums
5a33982e7d3ca76883837c569e56a22f0c9f9ac5edd740922e2f34c0be1ecfe0
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.4

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.4.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