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.0.tar.gz (8.5 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.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: janus_validation-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 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.0.tar.gz
Algorithm Hash digest
SHA256 9a218bbf626e5a5b8475a47e9ade45153659e867abf39dd9e55b8aebfd1ae30d
MD5 11ec56afeb60c3c0fcea3b884daf955e
BLAKE2b-256 5ac4f5c60be6fac948f2174c25ab219ff25833180351da7d73cae6dd638a385c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for janus_validation-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c9a3f2750bd453f1668a34599d04011e24348a0ca691b3857838cfe51a1a425
MD5 0bb9a29e21d9951f7da8f7708b189720
BLAKE2b-256 d5652e1be4cb9e0ed2ae158e9af18cd3f64b2de01a979a95fb41d630566557a5

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