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

Built distributions (wheels)

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

Total release size: 959.9 kB

Release files / appsync_scalars-0.1.1.tar.gz

Download URL appsync_scalars-0.1.1.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dcbd5cb01b38e30d3bd7cb1157145cd6969de069bfdf0a0d5ffa28bca9e362f2
BLAKE2b-256 checksum
How to use checksums
a54d0e2b56e5721ed695b7ee0e7f802ed674c2384a5ed248487339ca40267bb8
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.1-cp310-abi3-win_amd64.whl

Download URL appsync_scalars-0.1.1-cp310-abi3-win_amd64.whl
Size 108.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
133ff8a6514b5700977150c816c04625483e989bcfdc45c91c0be532f4b95316
BLAKE2b-256 checksum
How to use checksums
9cb80c9650cde75f129021e25a41fc727084f9c1aa2443cbef5cfc05a61d2122
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.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL appsync_scalars-0.1.1-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
417999caa34cac8b7f1f2103cfa68972ad7125285f3c7ec850f4d7bfa96ecfc6
BLAKE2b-256 checksum
How to use checksums
e6da7b38b14ccd1776d04fef049fec1a9f4767912352f04e99d1b0308c869f81
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.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL appsync_scalars-0.1.1-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
8f5a34f5102574ca3d7707255ec25ee3c8aaf8dbe58780a5d4e644237832f4df
BLAKE2b-256 checksum
How to use checksums
ddd21fd115b651970971cba4429c302f9e4a3208647d29ef3c6ad25234fd34ea
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.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL appsync_scalars-0.1.1-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
8186a88fa1daa27e36182491fd5dbc7ef6971f07ae5efca95e2d6a4c83c744d4
BLAKE2b-256 checksum
How to use checksums
72747086da46cb3dbf339d8e26ad489cd1c2df0648f6e7dd3e0dba98565afc53
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.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL appsync_scalars-0.1.1-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
9d204e5b5e703fa3c1b3f03625c9c89a2ac0a56cbe930a8e9d8913be6d7ecde0
BLAKE2b-256 checksum
How to use checksums
8d1940bbe5820f26cb547e5e2aa295dbb758b17bfc8a84e670c2dcd706c275c4
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.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.

Full provenance

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

Select from 6 files

Attestation for appsync_scalars-0.1.1.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