Registry / serialization / rfc3339-validator

rfc3339-validator

JSON →
library0.1.4pypypi✓ verified 28d ago

rfc3339-validator is a lightweight, pure Python library designed for strictly validating date-time strings against the RFC 3339 Internet Date/Time Format specification. Currently at version 0.1.4, its last release was in May 2021, indicating a mature, low-cadence project that provides a focused utility for ensuring RFC 3339 compliance in applications requiring precise time formatting, such as web APIs and data serialization.

pip install rfc3339-validator
INSTALL
IMPORT
SIG · RFC3339-VALIDATOR
R
rfc3339-validator
serializationpythonv0.1.4
Install
1.7s avg
Import
20ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.020s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.020s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

validate_rfc3339
✓ from rfc3339_validator import validate_rfc3339
✗ from rfc3339_validator import validate
The primary validation function is named `validate_rfc3339`, not a generic `validate`.

The library provides a single, straightforward function, `validate_rfc3339`, which takes a string and returns `True` if it conforms to the RFC 3339 specification, and `False` otherwise. RFC 3339 strictly requires a timezone offset (e.g., '+09:00', '-05:00') or 'Z' for UTC.

from rfc3339_validator import validate_rfc3339 # Valid RFC3339 datetime print(validate_rfc3339('2001-10-23T15:32:12.9023368Z')) # Invalid RFC3339 datetime print(validate_rfc3339('1424-45-93T15:32:12.9023368Z')) # Another valid example with offset print(validate_rfc3339('2023-09-24T15:30:00+09:00')) # Invalid: missing timezone/offset, RFC3339 requires it print(validate_rfc3339('2023-09-24T15:30:00'))
Debug
Known issues
gotchaRFC 3339 is a strict profile of ISO 8601. This validator enforces strict compliance, meaning common deviations like using a space instead of 'T' between date and time, or omitting timezone information (offset or 'Z'), will result in validation failure.
fix
Ensure all date-time strings conform precisely to RFC 3339, including the 'T' separator and a mandatory timezone offset (e.g., '+00:00', '-05:00', or 'Z' for UTC).
affects: All versions
gotchaThe library does not support validation or handling of leap seconds. As standard timestamps do not generally account for leap seconds, RFC 3339 validators typically do not either. This is a characteristic of the standard itself.
fix
For applications requiring leap second awareness, additional, specialized logic or libraries would be necessary beyond standard RFC 3339 validation.
affects: All versions
gotchaWhile Python's `datetime` objects can be used for RFC 3339 representation, improper handling of timezones (e.g., naive datetimes or incorrectly applied local timezones) can lead to invalid RFC 3339 strings, as RFC 3339 strictly requires an explicit UTC offset or 'Z'.
fix
Always use timezone-aware `datetime` objects, preferably `timezone.utc` or `datetime.now(timezone.utc)`, and ensure output formatting includes the correct offset or 'Z' when constructing RFC 3339 strings to be validated.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rfc3339_validator'
The rfc3339-validator library has not been installed, or the Python environment where the code is run does not have access to it.
fix
Run `pip install rfc3339-validator` to install the library.
ImportError: cannot import name 'validate' from 'rfc3339_validator'
The user is attempting to import a function named `validate` from the module, but the correct function name for validation is `validate_rfc3339`.
fix
Use the correct function name: `from rfc3339_validator import validate_rfc3339`
AttributeError: module 'rfc3339_validator' has no attribute 'validate'
After importing the `rfc3339_validator` module, the user is attempting to call a method named `validate` which does not exist; the correct function name is `validate_rfc3339`.
fix
Call the correct validation function: `rfc3339_validator.validate_rfc3339(date_string)`
TypeError: expected string, got <type>
The `validate_rfc3339` function expects a string as its argument, but it received a different data type (e.g., int, float, or None).
fix
Ensure that the argument passed to `validate_rfc3339` is always a string. Convert non-string inputs to strings before validation, for example: `validate_rfc3339(str(value))`.
Upgrade
Version history
0.1.4latest on PyPI · released May 12, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
rfc3339-validator — pip install rfc3339-validator · libregistry