Skip to content

Janus is a Python library designed for robust data validation, serialization, and schema versioning. It offers a comprehensive toolkit to handle input validation, data transformation, and API schema evolution, making it ideal for modern Python applications that require data integrity and compatibility.

License

Notifications You must be signed in to change notification settings

altxriainc/janus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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": "[email protected]", "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": "[email protected]"}
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

About

Janus is a Python library designed for robust data validation, serialization, and schema versioning. It offers a comprehensive toolkit to handle input validation, data transformation, and API schema evolution, making it ideal for modern Python applications that require data integrity and compatibility.

Topics

Resources

License

Stars

Watchers

Forks

Languages