Skip to main content

A Python library for robust data validation, serialization, and schema versioning.

Project description

Janus

Latest Version Downloads Status License: MIT

Janus is a modern Python library for data validation, serialization, and schema versioning. It provides developers with a flexible, performant, and extensible toolkit to handle input validation, data transformation, and API schema compatibility with ease.

Click here for the documentation


🚀 Key Features

  • Robust Data Validation: Includes a comprehensive set of validators for strings, numbers, dates, collections, and more.
  • Nested Schema Validation: Supports complex and deeply nested data structures.
  • Schema Versioning: Seamlessly handle schema evolution and data migration between API versions.
  • Serialization: Convert Python objects to JSON or YAML formats with error handling.
  • Custom Validators: Easily extend Janus with custom validation rules.
  • Open for Personal & Commercial Use: Use Janus freely in personal and commercial projects (not for resale as a standalone product).

🛠️ How to Use Janus

Step 1: Install Janus

Install Janus via pip:

pip install janus-validation

Step 2: Validate Your First Data

Define a validation schema:

from janus.utils.validators import is_required, is_type, is_email
from janus.core.validator import SchemaValidator

schema = {
    "name": [is_required, is_type(str)],
    "email": [is_required, is_email],
    "age": [is_type(int)],
}

validator = SchemaValidator(schema)

data = {"name": "Alice", "email": "alice@example.com", "age": 30}
validated_data = validator.validate(data)
print("Validated Data:", validated_data)

Step 3: Use Schema Versioning

Manage schema evolution with ease:

from janus.core.schema_versioning import SchemaVersioning

versioning = SchemaVersioning()

# Register schemas
versioning.register_schema("v1", {"name": [is_required]})
versioning.register_schema("v2", {"name": [is_required], "email": [is_email]})

# Validate data with specific schema versions
data = {"name": "Alice", "email": "alice@example.com"}
validated = versioning.validate_with_version("v2", data)
print("Validated:", validated)

Step 4: Serialize Data

Convert Python objects to JSON or YAML:

from janus.core.serializer import JSONSerializer, YAMLSerializer

serializer = JSONSerializer()
json_data = serializer.serialize({"name": "Alice", "age": 30})
print("Serialized JSON:", json_data)

yaml_serializer = YAMLSerializer()
yaml_data = yaml_serializer.serialize({"name": "Alice", "age": 30})
print("Serialized YAML:", yaml_data)

🔍 Project Status

Issues Closed Bug Issues Enhancement Issues


📜 License and Usage

Janus is free to use for both personal and commercial projects. However, Janus itself cannot be resold or distributed as a standalone product.


🤝 Contributors

Developed and maintained by Altxria Inc. with contributions from a growing community of passionate developers.

Contributors

See All Contributors


❤️ Support Janus

If you find Janus useful, consider sponsoring us to support ongoing development and new features!

Sponsor Janus

ko-fi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

janus_validation-0.1.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

janus_validation-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file janus_validation-0.1.1.tar.gz.

File metadata

  • Download URL: janus_validation-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for janus_validation-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fee86cfe45d9593df62f9c734931319a7dca6fad16bb47cac2f5bbe21a804e52
MD5 58a3a774cb25e09b519ed1f82cde21e4
BLAKE2b-256 7464bbf74a0f20ef013fbd976097b1ee4491d56e4d9d756a6ef8a8c5ebe0b16e

See more details on using hashes here.

File details

Details for the file janus_validation-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for janus_validation-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d05413a04a9a8168edf55a6dff80d396e65e7e8797498cae1c8da5651c54e33
MD5 1561b499fc98f1b6b545377f1817d3a2
BLAKE2b-256 4d487414dad2b8191f759b7e489d71316940863986c78ba93080d869c5a83410

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page