Skip to main content

A wrapper package for the jsonschema library to validate JSON data against a schema.

Project description

JSON Validation

This Python package provides a simple and intuitive way to validate JSON data against a specified schema. It is designed to be easy to use and highly customizable.

Installation

You can install JSON Validation using pip:

pip install json-validation

Usage

To use JSON Validation in your Python code, you first need to import the Validator class:

from json_validation import Validator

Next, you can create an instance of the Validator class and specify the JSON schema you want to validate against:

validator = Validator(schema)

You can then use the validate method to validate your JSON data:

result = validator.validate(data)

The validate method returns a boolean value indicating whether the data is valid according to the schema. You can also access detailed validation errors using the errors property of the Validator instance.

Examples

Here are some examples to help you get started:

# Create a schema
schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "number"}
    },
    "required": ["name"]
}

# Create a Validator instance
validator = Validator(schema)

# Validate JSON data
data = {
    "name": "John",
    "age": 30
}
result = validator.validate(data)

if result:
    print("Data is valid!")
else:
    print("Data is invalid.")
    print(validator.errors)

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

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

json_validation_al-0.0.9.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

json_validation_al-0.0.9-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file json_validation_al-0.0.9.tar.gz.

File metadata

  • Download URL: json_validation_al-0.0.9.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for json_validation_al-0.0.9.tar.gz
Algorithm Hash digest
SHA256 030d914041cb239b15d1877c518ae097854046ff9deb6424f2d3f83edf73c623
MD5 1c87ad3f8e2f97543cc7e62c85ef82dd
BLAKE2b-256 4c7f35c79d3ae39308ddaaaa7a06275fe2c741dfaa7a1ad786d254ac003adf99

See more details on using hashes here.

File details

Details for the file json_validation_al-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for json_validation_al-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 83a44b2066dc806625315f346b62288d2072def35eafdefa6ddb37e53a2450b4
MD5 1f4d7024e706bc25dc83e859cd932eed
BLAKE2b-256 0fc239c439be5ba440db1113475f1b1b3b1dccb50d4615652931cd63603450a7

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