jsvl


Namejsvl JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/syedowaisali/json-validator-python
Summary
upload_time2024-01-09 17:36:58
maintainer
docs_urlNone
authorSyed Owais Ali
requires_python>=3.6
licenseGPL
keywords python json schema validation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JSON Validator

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![GitHub issues](https://img.shields.io/github/issues/syedowaisali/json-validator-python)](https://github.com/syedowaisali/json-validator-python/issues)
[![GitHub stars](https://img.shields.io/github/stars/syedowaisali/json-validator-python)](https://github.com/syedowaisali/json-validator-python/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/syedowaisali/json-validator-python)](https://github.com/syedowaisali/json-validator-python/network)

**JSON Validator** is a Python library designed to enhance the validation of JSON documents. It provides a simple yet powerful set of features for schema-based validation, offering flexibility and precision in handling JSON data.

## Outline

- [Overview](#overview)
- [Key Features](#key-features)
   - [Schema Definition](#1-schema-definition)
   - [Flexible Data Type Validation](#2-flexible-data-type-validation)
   - [Key Presence Validation](#3-key-presence-validation)
   - [Required and Optional Fields](#4-required-and-optional-fields)
   - [Child Value Bypass](#5-child-value-bypass)
   - [Value Bindings](#6-value-bindings)
   - [Regular Expression Bindings](#7-regular-expression-bindings)
   - [String Value Constraints](#8-string-value-constraints)
   - [Numeric Value Constraints](#9-numeric-value-constraints)
   - [Case Constraints](#10-case-constraints)
   - [Spacing in String Values](#11-spacing-in-string-values)
   - [Custom Extension Library](#12-custom-extension-library)
- [Installation](#installation)
- [Command line guide](#command-line-guide)
- [How to use](#how-to-use)
- [Use in Project](#use-in-project)
- [Control Configs](#control-configs)
- [Register Custom Validation Filters](#register-custom-validation-filters)
- [User guide](#user-guide)
- [Available Keywords](#available-keywords)
- [Support Data Types](#support-data-types)
- [License](#license)

## Overview

**JSON Validator** is a feature-rich Python library designed to elevate the validation of JSON documents by offering an extensive schema-based validation system. It empowers developers to define custom schemas, providing fine-grained control over the structure, data types, and constraints of their JSON data.

## Key Features

### 1. Schema Definition

Define a schema for your JSON documents, specifying keys, data types, and constraints. The schema acts as a blueprint for validation.

### 2. Flexible Data Type Validation

Control the data types of each key in your JSON document. Enforce strict typing or allow flexibility based on your requirements.

### 3. Key Presence Validation

Detect and handle invalid keys in your JSON document that are not defined in the schema, ensuring data integrity.

### 4. Required and Optional Fields

Designate which fields are required and which are optional, guiding users in creating valid JSON documents.

### 5. Child Value Bypass

Allow bypassing the validation of child values, providing flexibility when certain sections of the JSON document don't require strict validation.

### 6. Value Bindings

Support value bindings to establish relationships between different parts of the JSON document, enhancing the expressiveness of your schemas.

### 7. Regular Expression Bindings

Support regular expression bindings for precise validation of values..

### 8. String Value Constraints

Control the minimum and maximum length of string values, applying constraints to ensure data meets specific length requirements.

### 9. Numeric Value Constraints

Define minimum and maximum values for integer and float types, allowing precise control over the numeric range of your data.

### 10. Case Constraints

Apply case constraints to string types, specifying whether they should be in lower, upper, or mixed case.

### 11. Spacing in String Values

Optionally allow spacing in string data types, enhancing readability in scenarios where formatted text is essential.

### 12. Custom Extension Library

Extend the functionality of the library by creating custom extensions, tailoring the validation process to your unique needs.

### Installation
```commandline
pip install jsvl -U
```
### Command line guide
List of available commands

| Command                              | Definition                                                                                                                                                                                                       |
|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -s or --schema                       | Provide a schema as URL, JSON, file or a directory for validating the documents.                                                                                                                             | 
| -d or --doc                          | Provide a document json, file or a directory path for validation.<br/>Note: if the schema source is a directory then provided schema should be in a directory and should have the same name with _schema postfix. |
| -csfp or --change-schema-file-postfix | This argument will be used to change the schema file postfix name.                                                                                                                                               |
| --disable-tags                       | Pass this flag to disable the output tags from logs.                                                                                                                                                             |
| --plain-output                       | Pass this flag to remove the formatting from logs.                                                                                                                                                               |
| --disable-logs                       | Pass this flag to disable all the logs.                                                                                                                                                                          |
| --show-validation-source             | Pass this flag to show the validation class name with logs.                                                                                                                                                      |
| --tight-space                        | Pass this flag to disable the allow_space globally.                                                                                                                                                              |
| -ml or --min-length                  | Set the minimum length globally, default is 0.                                                                                                                                                                   |
| -xl or --max-length                  | Set the maximum length globally, default is None.                                                                                                                                                                |
| -mv or --min-value                   | Set the minimum value globally, default is 0.                                                                                                                                                                    |
| -xv or --max-value                   | Set the maximum value globally, default is None.                                                                                                                                                                 |
| -c or --case                         | Set the text constraints globally, default is None. set [Available Keywords](#available-keywords)                                                                                                                |
| -v or --version                      | Check version.                                                                                                                                                                                                   |
| -h or --help                         | For help.                                                                                                                                                                                                        |

### How to use
**Command line**

Validate a single json document.
```commandline
~$ jsvl -s /path/to/schema.json -d /path/to/document.json
```
Validate a single json document with URL.
```commandline
~$ jsvl -s http://www.yourdomain.com/schema.json -d /path/to/document.json
```
Validate multiple documents with a single schema.
```commandline
~$ jsvl -s /path/to/schema.json -d /path/to/documents/
```
Validate multiple documents with multiple schema.
```commandline
~$ jsvl -s /path/to/schema/ -d /path/to/documents/
```
Disable informative tags from the output.
```commandline
~$ jsvl -s path/to/schema.json -d /path/to/document.json --disable-tags
```
Remove formatting from the output.
```commandline
~$ jsvl -s path/to/schema.json -d /path/to/document.json --plain-output
```

### Use in Project:

Import **validate** function from **jsvl.core.validator** module and validate the document with multiple options.
```python
from jsvl.core.validator import validate

# schema json
schema = "http://www.youdomain.com/schema.json" or "path/to/schema.json" or "path/to/all_schema_dir/" or {}

# document json
document = "path/to/document.json" or "path/to/all_documents_dir/" or {} or []

# perform validation
result = validate(schema, document)
```
### Control Configs:

```python
import jsvl.config as cfg
from jsvl.utils.util import reserved_key

# change schema file postfix default is _schema
cfg.configs[cfg.schema_file_postfix] = "_schema"

# disable the output tags from logs
cfg.configs[cfg.enable_output_tags] = False

# remove the formatting from logs
cfg.configs[cfg.formatted_output] = False

# disable all the logs
cfg.configs[cfg.enable_output_logs] = True

# show the validation class name with logs
cfg.configs[cfg.enable_validation_source] = True

# disable the allow_space globally
cfg.configs[cfg.allow_space] = True

# set the minimum length globally, default is 0.
cfg.configs[cfg.min_length] = 0

# set the maximum length globally, default is None.
cfg.configs[cfg.max_length] = 1000

# set the minimum value globally, default is 0.
cfg.configs[cfg.min_value] = 0

# set the maximum value globally, default is None.
cfg.configs[cfg.max_value] = 1000

# set the text constraints globally, default is None.
cfg.configs[cfg.case] = reserved_key.upper
```
### Register Custom Validation Filters:

You can register two types of validation filter.
1. **Schema Validation**

```python
from jsvl.validations.schema_validations import schema_validation_set, SchemaValidation

# creating custom validation class for schema validation
class CustomSchemaValidation(SchemaValidation):

    def validate(self, key, schema, path):
        pass

# register validation in schema validation set
schema_validation_set.add(CustomSchemaValidation())
```
2. **Document Validation**
```python
from jsvl.validations.doc_validations import doc_validation_set, DocValidation

# creating custom validation class for document validation
class CustomDocValidation(DocValidation):

    def validate(self, key, schema, doc, path, index, doc_is_dynamic):
        pass

# register validation in document validation set
doc_validation_set.add(CustomDocValidation())

```
### User guide
Validating a sample document.

> **schema.json**
```json
{
    "cart": {
        "__data_type__": "object",
        "items*": {
            "__data_type__": "object_array",
            "title*": {
              "__case__": "__title__"
            },
            "description": {
              "__min_length__": 20
            },
            "email": {
              "__bind_regex__": "__email__"
            },
            "category*": {
              "__bind__": "category"
            },
            "keywords": {
              "__bind_regex__": "^[a-zA-Z]+$",
              "__rem__": "support only alphabets"
            },
            "quantity*": {
                "__data_type__": "integer",
                "__min_value__": 1
            },
            "discount*": {
                "__data_type__": "float",
                "__max_value__": 45.5
            }
        }
    },
    "~others": {},
    "__binder__": {
        "category": ["Health", "Fashion", "Lifestyle"]
    },
    "__defaults__": {
      "__min_value__": 100,
      "__max_value__": 1000
    }
}
```

> **document.json**

```json
{
    "cart": {
      "items": [
        {
          "title": "Product 1",
          "description": "",
          "email": "john@gmail.com",
          "quantity": 1,
          "category": "Fashion",
          "keywords": "Health",
          "discount": 30.0
        },
        {
          "title": "Product 2",
          "quantity": 4,
          "category": "Health",
          "keywords": "Health",
          "discount": 0.0
        }
      ]
    },
    "others": {
      "coords": {
        "lat": 0.022,
        "lng": 2.34
      }
    }
}
```
### Available keywords:

|        Keyword         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                             |   Default    |                           Scope                           |
|:----------------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------:|:---------------------------------------------------------:|
|        <b>*</b>        | Add an asterisk keyword to the end of the key to mark it as required.                                                                                                                                                                                                                                                                                                                                                                                   | ```false```  | Could be add on any keyword. Excluded `reserved keywords` |
|         **~**          | Add a tilde keyword to the start of the key to bypass all the validation of the immediate child.                                                                                                                                                                                                                                                                                                                                                        |  ```none```  | Could be add on any keyword. Excluded `reserved keywords` |
| **\_\_data_type\_\_**  | Set data type on field, multiple data types could be supplied using pipe \| for example. ```string\|object```.                                                                                                                                                                                                                                                                                                                                          | ```string``` |                         `object`                          |
| **\_\_alow_space\_\_** | Allow space on text.                                                                                                                                                                                                                                                                                                                                                                                                                                    |  ```true```  |                         `string`                          |
| **\_\_min_length\_\_** | Set the minimum length.                                                                                                                                                                                                                                                                                                                                                                                                                                 |   ```0```    |             `string` and any type of `array`              |
| **\_\_max_length\_\_** | Set the maximum length.                                                                                                                                                                                                                                                                                                                                                                                                                                 |  ```none```  |             `string` and any type of `array`              |
| **\_\_min_value\_\_**  | Set the minimum value.                                                                                                                                                                                                                                                                                                                                                                                                                                  |   ```0```    |                   `integer` and `float`                   |
| **\_\_max_value\_\_**  | Set the maximum value.                                                                                                                                                                                                                                                                                                                                                                                                                                  |  ```none```  |                   `integer` and `float`                   |
|    **\_\_case\_\_**    | Apply case constraint on value.<br /><br />**Available case constraints:**<ol><li><code>\_\_upper\_\_</code></li><li><code>\_\_lower\_\_</code></li><li><code>\_\_title\_\_</code></li></ol>                                                                                                                                                                                                                                                            |  ```none```  |                         `string`                          |
| **\_\_bind_regex\_\_** | Apply custom regular expression or use some pre-define. <code>Note:</code> **\_\_bind_regex\_\_** will take higher precedence over **\_\_bind\_\_** if both are defined.<br /><br />**Some pre-defined expressions:**<ol><li><code>\_\_email\_\_</code></li><li><code>\_\_alpha\_\_</code></li><li><code>\_\_numeric\_\_</code></li><li><code>\_\_alphanumeric\_\_</code></li><li><code>\_\_ipv4\_\_</code></li><li><code>\_\_ipv6\_\_</code></li></ol> | ```false```  |                         `string`                          |
|    **\_\_rem\_\_**     | Proivde custom error when regex gets failed.                                                                                                                                                                                                                                                                                                                                                                                                            | ```false```  |                         `string`                          |
|    **\_\_bind\_\_**    | Bind value from defined valueset.                                                                                                                                                                                                                                                                                                                                                                                                                       |  ```none```  |                   ignore the data type                    |
|   **\_\_binder\_\_**   | This is a special keyword and that will be used only root object of the schema where you can define binding valueset.                                                                                                                                                                                                                                                                                                                                   |  ```none```  |                    only root `object`                     |
|  **\_\_defaults\_\_**  | This is a special keyword and that will be used to apply the defined constraints globally on the document.<br /><br />**Available properties that could be set globally:**<br /><ol><li><code>\_\_allow_space\_\_</code></li><li><code>\_\_min_length\_\_</code></li><li><code>\_\_max_length\_\_</code></li><li><code>\_\_min_value\_\_</code></li><li><code>\_\_max_value\_\_</code></li><li><code>\_\_case\_\_</code></li></ol>                      |  ```none```  |                     only root `object`                     |

### Support Data Types

- ```string```
- ```integer```
- ```float```
- ```bool```
- ```object```
- ```string_array```
- ```integer_array```
- ```float_array```
- ```bool_array```
- ```array```

# License

[GPL v3](https://github.com/syedowaisali/json-validator-python/blob/main/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/syedowaisali/json-validator-python",
    "name": "jsvl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python json schema validation",
    "author": "Syed Owais Ali",
    "author_email": "dp.owaisali@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d2/ad/db4cf43ae39f51f08ac387fb249414c3dcf48ee85db83565c00830228cbe/jsvl-1.1.0.tar.gz",
    "platform": null,
    "description": "# JSON Validator\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![GitHub issues](https://img.shields.io/github/issues/syedowaisali/json-validator-python)](https://github.com/syedowaisali/json-validator-python/issues)\n[![GitHub stars](https://img.shields.io/github/stars/syedowaisali/json-validator-python)](https://github.com/syedowaisali/json-validator-python/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/syedowaisali/json-validator-python)](https://github.com/syedowaisali/json-validator-python/network)\n\n**JSON Validator** is a Python library designed to enhance the validation of JSON documents. It provides a simple yet powerful set of features for schema-based validation, offering flexibility and precision in handling JSON data.\n\n## Outline\n\n- [Overview](#overview)\n- [Key Features](#key-features)\n   - [Schema Definition](#1-schema-definition)\n   - [Flexible Data Type Validation](#2-flexible-data-type-validation)\n   - [Key Presence Validation](#3-key-presence-validation)\n   - [Required and Optional Fields](#4-required-and-optional-fields)\n   - [Child Value Bypass](#5-child-value-bypass)\n   - [Value Bindings](#6-value-bindings)\n   - [Regular Expression Bindings](#7-regular-expression-bindings)\n   - [String Value Constraints](#8-string-value-constraints)\n   - [Numeric Value Constraints](#9-numeric-value-constraints)\n   - [Case Constraints](#10-case-constraints)\n   - [Spacing in String Values](#11-spacing-in-string-values)\n   - [Custom Extension Library](#12-custom-extension-library)\n- [Installation](#installation)\n- [Command line guide](#command-line-guide)\n- [How to use](#how-to-use)\n- [Use in Project](#use-in-project)\n- [Control Configs](#control-configs)\n- [Register Custom Validation Filters](#register-custom-validation-filters)\n- [User guide](#user-guide)\n- [Available Keywords](#available-keywords)\n- [Support Data Types](#support-data-types)\n- [License](#license)\n\n## Overview\n\n**JSON Validator** is a feature-rich Python library designed to elevate the validation of JSON documents by offering an extensive schema-based validation system. It empowers developers to define custom schemas, providing fine-grained control over the structure, data types, and constraints of their JSON data.\n\n## Key Features\n\n### 1. Schema Definition\n\nDefine a schema for your JSON documents, specifying keys, data types, and constraints. The schema acts as a blueprint for validation.\n\n### 2. Flexible Data Type Validation\n\nControl the data types of each key in your JSON document. Enforce strict typing or allow flexibility based on your requirements.\n\n### 3. Key Presence Validation\n\nDetect and handle invalid keys in your JSON document that are not defined in the schema, ensuring data integrity.\n\n### 4. Required and Optional Fields\n\nDesignate which fields are required and which are optional, guiding users in creating valid JSON documents.\n\n### 5. Child Value Bypass\n\nAllow bypassing the validation of child values, providing flexibility when certain sections of the JSON document don't require strict validation.\n\n### 6. Value Bindings\n\nSupport value bindings to establish relationships between different parts of the JSON document, enhancing the expressiveness of your schemas.\n\n### 7. Regular Expression Bindings\n\nSupport regular expression bindings for precise validation of values..\n\n### 8. String Value Constraints\n\nControl the minimum and maximum length of string values, applying constraints to ensure data meets specific length requirements.\n\n### 9. Numeric Value Constraints\n\nDefine minimum and maximum values for integer and float types, allowing precise control over the numeric range of your data.\n\n### 10. Case Constraints\n\nApply case constraints to string types, specifying whether they should be in lower, upper, or mixed case.\n\n### 11. Spacing in String Values\n\nOptionally allow spacing in string data types, enhancing readability in scenarios where formatted text is essential.\n\n### 12. Custom Extension Library\n\nExtend the functionality of the library by creating custom extensions, tailoring the validation process to your unique needs.\n\n### Installation\n```commandline\npip install jsvl -U\n```\n### Command line guide\nList of available commands\n\n| Command                              | Definition                                                                                                                                                                                                       |\n|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| -s or --schema                       | Provide a schema as URL, JSON, file or a directory for validating the documents.                                                                                                                             | \n| -d or --doc                          | Provide a document json, file or a directory path for validation.<br/>Note: if the schema source is a directory then provided schema should be in a directory and should have the same name with _schema postfix. |\n| -csfp or --change-schema-file-postfix | This argument will be used to change the schema file postfix name.                                                                                                                                               |\n| --disable-tags                       | Pass this flag to disable the output tags from logs.                                                                                                                                                             |\n| --plain-output                       | Pass this flag to remove the formatting from logs.                                                                                                                                                               |\n| --disable-logs                       | Pass this flag to disable all the logs.                                                                                                                                                                          |\n| --show-validation-source             | Pass this flag to show the validation class name with logs.                                                                                                                                                      |\n| --tight-space                        | Pass this flag to disable the allow_space globally.                                                                                                                                                              |\n| -ml or --min-length                  | Set the minimum length globally, default is 0.                                                                                                                                                                   |\n| -xl or --max-length                  | Set the maximum length globally, default is None.                                                                                                                                                                |\n| -mv or --min-value                   | Set the minimum value globally, default is 0.                                                                                                                                                                    |\n| -xv or --max-value                   | Set the maximum value globally, default is None.                                                                                                                                                                 |\n| -c or --case                         | Set the text constraints globally, default is None. set [Available Keywords](#available-keywords)                                                                                                                |\n| -v or --version                      | Check version.                                                                                                                                                                                                   |\n| -h or --help                         | For help.                                                                                                                                                                                                        |\n\n### How to use\n**Command line**\n\nValidate a single json document.\n```commandline\n~$ jsvl -s /path/to/schema.json -d /path/to/document.json\n```\nValidate a single json document with URL.\n```commandline\n~$ jsvl -s http://www.yourdomain.com/schema.json -d /path/to/document.json\n```\nValidate multiple documents with a single schema.\n```commandline\n~$ jsvl -s /path/to/schema.json -d /path/to/documents/\n```\nValidate multiple documents with multiple schema.\n```commandline\n~$ jsvl -s /path/to/schema/ -d /path/to/documents/\n```\nDisable informative tags from the output.\n```commandline\n~$ jsvl -s path/to/schema.json -d /path/to/document.json --disable-tags\n```\nRemove formatting from the output.\n```commandline\n~$ jsvl -s path/to/schema.json -d /path/to/document.json --plain-output\n```\n\n### Use in Project:\n\nImport **validate** function from **jsvl.core.validator** module and validate the document with multiple options.\n```python\nfrom jsvl.core.validator import validate\n\n# schema json\nschema = \"http://www.youdomain.com/schema.json\" or \"path/to/schema.json\" or \"path/to/all_schema_dir/\" or {}\n\n# document json\ndocument = \"path/to/document.json\" or \"path/to/all_documents_dir/\" or {} or []\n\n# perform validation\nresult = validate(schema, document)\n```\n### Control Configs:\n\n```python\nimport jsvl.config as cfg\nfrom jsvl.utils.util import reserved_key\n\n# change schema file postfix default is _schema\ncfg.configs[cfg.schema_file_postfix] = \"_schema\"\n\n# disable the output tags from logs\ncfg.configs[cfg.enable_output_tags] = False\n\n# remove the formatting from logs\ncfg.configs[cfg.formatted_output] = False\n\n# disable all the logs\ncfg.configs[cfg.enable_output_logs] = True\n\n# show the validation class name with logs\ncfg.configs[cfg.enable_validation_source] = True\n\n# disable the allow_space globally\ncfg.configs[cfg.allow_space] = True\n\n# set the minimum length globally, default is 0.\ncfg.configs[cfg.min_length] = 0\n\n# set the maximum length globally, default is None.\ncfg.configs[cfg.max_length] = 1000\n\n# set the minimum value globally, default is 0.\ncfg.configs[cfg.min_value] = 0\n\n# set the maximum value globally, default is None.\ncfg.configs[cfg.max_value] = 1000\n\n# set the text constraints globally, default is None.\ncfg.configs[cfg.case] = reserved_key.upper\n```\n### Register Custom Validation Filters:\n\nYou can register two types of validation filter.\n1. **Schema Validation**\n\n```python\nfrom jsvl.validations.schema_validations import schema_validation_set, SchemaValidation\n\n# creating custom validation class for schema validation\nclass CustomSchemaValidation(SchemaValidation):\n\n    def validate(self, key, schema, path):\n        pass\n\n# register validation in schema validation set\nschema_validation_set.add(CustomSchemaValidation())\n```\n2. **Document Validation**\n```python\nfrom jsvl.validations.doc_validations import doc_validation_set, DocValidation\n\n# creating custom validation class for document validation\nclass CustomDocValidation(DocValidation):\n\n    def validate(self, key, schema, doc, path, index, doc_is_dynamic):\n        pass\n\n# register validation in document validation set\ndoc_validation_set.add(CustomDocValidation())\n\n```\n### User guide\nValidating a sample document.\n\n> **schema.json**\n```json\n{\n    \"cart\": {\n        \"__data_type__\": \"object\",\n        \"items*\": {\n            \"__data_type__\": \"object_array\",\n            \"title*\": {\n              \"__case__\": \"__title__\"\n            },\n            \"description\": {\n              \"__min_length__\": 20\n            },\n            \"email\": {\n              \"__bind_regex__\": \"__email__\"\n            },\n            \"category*\": {\n              \"__bind__\": \"category\"\n            },\n            \"keywords\": {\n              \"__bind_regex__\": \"^[a-zA-Z]+$\",\n              \"__rem__\": \"support only alphabets\"\n            },\n            \"quantity*\": {\n                \"__data_type__\": \"integer\",\n                \"__min_value__\": 1\n            },\n            \"discount*\": {\n                \"__data_type__\": \"float\",\n                \"__max_value__\": 45.5\n            }\n        }\n    },\n    \"~others\": {},\n    \"__binder__\": {\n        \"category\": [\"Health\", \"Fashion\", \"Lifestyle\"]\n    },\n    \"__defaults__\": {\n      \"__min_value__\": 100,\n      \"__max_value__\": 1000\n    }\n}\n```\n\n> **document.json**\n\n```json\n{\n    \"cart\": {\n      \"items\": [\n        {\n          \"title\": \"Product 1\",\n          \"description\": \"\",\n          \"email\": \"john@gmail.com\",\n          \"quantity\": 1,\n          \"category\": \"Fashion\",\n          \"keywords\": \"Health\",\n          \"discount\": 30.0\n        },\n        {\n          \"title\": \"Product 2\",\n          \"quantity\": 4,\n          \"category\": \"Health\",\n          \"keywords\": \"Health\",\n          \"discount\": 0.0\n        }\n      ]\n    },\n    \"others\": {\n      \"coords\": {\n        \"lat\": 0.022,\n        \"lng\": 2.34\n      }\n    }\n}\n```\n### Available keywords:\n\n|        Keyword         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                             |   Default    |                           Scope                           |\n|:----------------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------:|:---------------------------------------------------------:|\n|        <b>*</b>        | Add an asterisk keyword to the end of the key to mark it as required.                                                                                                                                                                                                                                                                                                                                                                                   | ```false```  | Could be add on any keyword. Excluded `reserved keywords` |\n|         **~**          | Add a tilde keyword to the start of the key to bypass all the validation of the immediate child.                                                                                                                                                                                                                                                                                                                                                        |  ```none```  | Could be add on any keyword. Excluded `reserved keywords` |\n| **\\_\\_data_type\\_\\_**  | Set data type on field, multiple data types could be supplied using pipe \\| for example. ```string\\|object```.                                                                                                                                                                                                                                                                                                                                          | ```string``` |                         `object`                          |\n| **\\_\\_alow_space\\_\\_** | Allow space on text.                                                                                                                                                                                                                                                                                                                                                                                                                                    |  ```true```  |                         `string`                          |\n| **\\_\\_min_length\\_\\_** | Set the minimum length.                                                                                                                                                                                                                                                                                                                                                                                                                                 |   ```0```    |             `string` and any type of `array`              |\n| **\\_\\_max_length\\_\\_** | Set the maximum length.                                                                                                                                                                                                                                                                                                                                                                                                                                 |  ```none```  |             `string` and any type of `array`              |\n| **\\_\\_min_value\\_\\_**  | Set the minimum value.                                                                                                                                                                                                                                                                                                                                                                                                                                  |   ```0```    |                   `integer` and `float`                   |\n| **\\_\\_max_value\\_\\_**  | Set the maximum value.                                                                                                                                                                                                                                                                                                                                                                                                                                  |  ```none```  |                   `integer` and `float`                   |\n|    **\\_\\_case\\_\\_**    | Apply case constraint on value.<br /><br />**Available case constraints:**<ol><li><code>\\_\\_upper\\_\\_</code></li><li><code>\\_\\_lower\\_\\_</code></li><li><code>\\_\\_title\\_\\_</code></li></ol>                                                                                                                                                                                                                                                            |  ```none```  |                         `string`                          |\n| **\\_\\_bind_regex\\_\\_** | Apply custom regular expression or use some pre-define. <code>Note:</code> **\\_\\_bind_regex\\_\\_** will take higher precedence over **\\_\\_bind\\_\\_** if both are defined.<br /><br />**Some pre-defined expressions:**<ol><li><code>\\_\\_email\\_\\_</code></li><li><code>\\_\\_alpha\\_\\_</code></li><li><code>\\_\\_numeric\\_\\_</code></li><li><code>\\_\\_alphanumeric\\_\\_</code></li><li><code>\\_\\_ipv4\\_\\_</code></li><li><code>\\_\\_ipv6\\_\\_</code></li></ol> | ```false```  |                         `string`                          |\n|    **\\_\\_rem\\_\\_**     | Proivde custom error when regex gets failed.                                                                                                                                                                                                                                                                                                                                                                                                            | ```false```  |                         `string`                          |\n|    **\\_\\_bind\\_\\_**    | Bind value from defined valueset.                                                                                                                                                                                                                                                                                                                                                                                                                       |  ```none```  |                   ignore the data type                    |\n|   **\\_\\_binder\\_\\_**   | This is a special keyword and that will be used only root object of the schema where you can define binding valueset.                                                                                                                                                                                                                                                                                                                                   |  ```none```  |                    only root `object`                     |\n|  **\\_\\_defaults\\_\\_**  | This is a special keyword and that will be used to apply the defined constraints globally on the document.<br /><br />**Available properties that could be set globally:**<br /><ol><li><code>\\_\\_allow_space\\_\\_</code></li><li><code>\\_\\_min_length\\_\\_</code></li><li><code>\\_\\_max_length\\_\\_</code></li><li><code>\\_\\_min_value\\_\\_</code></li><li><code>\\_\\_max_value\\_\\_</code></li><li><code>\\_\\_case\\_\\_</code></li></ol>                      |  ```none```  |                     only root `object`                     |\n\n### Support Data Types\n\n- ```string```\n- ```integer```\n- ```float```\n- ```bool```\n- ```object```\n- ```string_array```\n- ```integer_array```\n- ```float_array```\n- ```bool_array```\n- ```array```\n\n# License\n\n[GPL v3](https://github.com/syedowaisali/json-validator-python/blob/main/LICENSE)\n",
    "bugtrack_url": null,
    "license": "GPL",
    "summary": "",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/syedowaisali/json-validator-python",
        "Issues": "https://github.com/syedowaisali/json-validator-python/issues",
        "Source Code": "https://github.com/syedowaisali/json-validator-python"
    },
    "split_keywords": [
        "python",
        "json",
        "schema",
        "validation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d2addb4cf43ae39f51f08ac387fb249414c3dcf48ee85db83565c00830228cbe",
                "md5": "f8a4bf275e4f076b174de8f12bc3cfce",
                "sha256": "fffb077e4e8fb9c4a38ceea380b2224b35fd66b674fec91a74831755b36d3f95"
            },
            "downloads": -1,
            "filename": "jsvl-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f8a4bf275e4f076b174de8f12bc3cfce",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 40233,
            "upload_time": "2024-01-09T17:36:58",
            "upload_time_iso_8601": "2024-01-09T17:36:58.890307Z",
            "url": "https://files.pythonhosted.org/packages/d2/ad/db4cf43ae39f51f08ac387fb249414c3dcf48ee85db83565c00830228cbe/jsvl-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-09 17:36:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "syedowaisali",
    "github_project": "json-validator-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "jsvl"
}
        
Elapsed time: 0.16534s