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

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.2
File Size Uploaded Provenance Actions
appsync_scalars-0.1.2.tar.gz 40.3 kB With provenance Details for appsync_scalars-0.1.2.tar.gz

Built distributions (wheels)

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

Total release size: 959.8 kB

Release files / appsync_scalars-0.1.2.tar.gz

Download URL appsync_scalars-0.1.2.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
18fc2ffb62351460cb7e6f9e3e6ebca8b4799ef5cc337302ad9a7da3c62375a2
BLAKE2b-256 checksum
How to use checksums
48db2b15eda5b47b93a0d3177d9cc5a3cc7830d3005d5df75b195c5cd8256f29
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.2-cp310-abi3-win_amd64.whl

Download URL appsync_scalars-0.1.2-cp310-abi3-win_amd64.whl
Size 108.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
33cea3c1c2006f9afd50ef4506eec1a14cabe0357128c0fb1a2d3392af651251
BLAKE2b-256 checksum
How to use checksums
cf5cc730e1430b21a4d7db6a43ca4596b9df8dbf68c03f9d752c152f9f74f728
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.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL appsync_scalars-0.1.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 221.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d4f66fc2b7201ce4c0b1fcdc0fd718ed9350955bf027430ccf5e63251218a7fb
BLAKE2b-256 checksum
How to use checksums
d468e27e2fff71716122b380cca6b5255ad183e86456dfc0f918ccc660a87774
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.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL appsync_scalars-0.1.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 215.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
7c8ed052358bf80558e48b35285199974b03b01a75921ee8f3bb20314221f125
BLAKE2b-256 checksum
How to use checksums
b38daf684736d1557fd31ee8828557b0ebea10cd39d85e13f874fabcb9d9502b
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.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL appsync_scalars-0.1.2-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
30d143be6f40f2bec07fd14e91033c4fec9c459dc765cc9af0150da4172c597f
BLAKE2b-256 checksum
How to use checksums
50713aff746bda2422de02b1fb22506338881504a8a6ab253e40fb96c81957e5
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.2-cp310-abi3-macosx_10_12_x86_64.whl

Download URL appsync_scalars-0.1.2-cp310-abi3-macosx_10_12_x86_64.whl
Size 188.3 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3255585ccc6473551e016d98da7e8bd2663eed146961247818a21caf880acc79
BLAKE2b-256 checksum
How to use checksums
ce72994224e824547c030bc5f1de412c47fd77f1ffab3e3145ee5a61fdc9e6a5
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.2

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