Metadata-Version: 2.1
Name: kanpai
Version: 0.1.2
Summary: Python JSON schema validator with better error message
Home-page: https://gitlab.com/chandrakantap/kanpai.git
Author: Chandrakanta Pal
Author-email: pal.chandrakanta@gmail.com
License: UNKNOWN
Description: **kanpai** is a library for validating Python data structures, mainly those coverted from JSON. e.g. JSON received from api request, obtained from config file etc.
        
        Example
        -------
        Here is a quick example
        
        ```python
        import kanpai as Kanpai
        
        schema = Kanpai.Object({
                'first_name': (Kanpai.String(error='User first name must be string.')
                               .trim()
                               .required(error='Please provide user first name.')
                               .max(256, error='Maximum allowed length is 256')),
        
                'last_name': (Kanpai.String(error='User last name must be a String')
                              .trim()
                              .required(error='Please provide user last name.')),
                
                'age'      : (Kanpai.Number(error='Age must be a number.')
                              .max(35,'Maximum allowed age is 35')
                              .min(18,'Age must be minimum 18'))
        
            })
        
        validation_result = schema.validate({
          'first_name':'Chandrakanta',
          'age': 15
        })
        
        assert validation_result == {
          'success': False,
          'error': {
            'last_name': 'Please provide user last name.',
            'age': 'Age must be minimum 18'
          },
          'data': {
             'first_name':'Chandrakanta',
             'age': 15
          }
        }
        ```
        
        ```schema.validate``` return a dictionary obejct containing 
        
        ```python
        {
         'success':'Whether validation is success or not',
         'error':'Validation error',
         'data':'Incase of error data provided for validation , in case success validated data'
        }
        ```
        
        
        Installation
        ------------
        
        Use [pip](http://pip-installer.org)
        
            pip install kanpai
        
        
        Test
        ----
        
        ```python
        pytest # to run tests
        pytest --cov-report=html  --cov-branch --cov=kanpai # to generate coverage report
        ```
        
Keywords: schema json validation request-validation input-validation
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
