rfc3339-validator

A pure Python regex-based validator for RFC3339 datetime strings

Library
PyPI
v0.1.4
8stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
24/100Needs Attention
Development Activity0
Maintenance20
Community16
Maturity60
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
54/100Fair
Architecture35
Code Quality60
Innovation30
Learning Curve90

rfc3339-validator is a tiny, dependency-light Python package that checks whether a string is a valid RFC3339 datetime, the timestamp format used throughout JSON Schema’s date-time format keyword. It exposes a single validate_rfc3339() function that returns True/False, using a compiled regular expression plus a calendar-aware day-of-month check to reject dates like February 30th.

Despite its tiny surface area, it is widely depended upon transitively — most notably by the jsonschema and openapi-schema-validator ecosystems — as the default date-time format checker, which is why it sees very high download volume relative to its size.

What You Get

  • A single validate_rfc3339(date_string) function returning a boolean
  • Regex-based format matching for the full RFC3339 date-time grammar, including fractional seconds and UTC/offset timezone suffixes
  • Calendar-aware day validation (rejects invalid dates like April 31st) via calendar.monthrange()
  • Zero heavyweight dependencies beyond the six compatibility shim

Common Use Cases

  • Implementing the date-time format checker for JSON Schema validation (used internally by jsonschema)
  • Validating timestamp fields in API request/response payloads before further processing
  • Sanity-checking timestamp strings pulled from logs, config files, or third-party APIs
  • Lightweight form/input validation where a full datetime-parsing library would be overkill

Under The Hood

Architecture — the entire implementation is a single module (rfc3339_validator.py) containing one compiled regex (RFC3339_REGEX) and one function (validate_rfc3339); the regex handles structural matching (year/month/day/time/timezone), and the function layers a calendar.monthrange() check on top to catch dates the regex alone would wrongly accept (e.g. February 30th).

Tech Stack — pure Python with a single runtime dependency on six for Python 2/3 compatibility flags; no compiled extensions, no async code, packaged via plain setuptools.

Code Qualitytests/test_rfc3339_validator.py exercises the validator against a table of valid and invalid date strings covering leap years, invalid months/days, and malformed timezone offsets; the codebase is small enough (under 50 lines) that the test-to-code ratio is high relative to complexity.

API Design — the API is a single function with a single string argument and boolean return, which is about as low-friction as an API can be; there’s no configuration, no exceptions to catch, and no state, making it trivial to drop into a validation pipeline or JSON Schema format-checker registry.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search