Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python cerberus

#!/usr/bin/env python

from cerberus import Validator


v = Validator()
v.schema = {"contact_details": {
    "type": "dict",
    "schema": {
        "phone": {
            "type": "string",
            "minlength": 10,
            "maxlength": 10,
            "regex": "^0[0-9]{9}$"
        },
        "email": {
            "type": "string",
            "minlength": 8,
            "maxlength": 255,
            "required": True,
            "regex": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$"
        }
    }
}}

if v.validate({'contact_details': {'phone': '0901123123',
                                   'email': 'john.doe@example.com'}}):
    print('valid data')
else:
    print('invalid data')
    print(v.errors)
Comment

python cerberus

#!/usr/bin/env python

from cerberus import Validator

v = Validator()
v.schema = {'name': { 'type': 'string', 'minlength': 25},
    'age': {'type': 'integer', 'min': 18, 'max': 65}}

if v.validate({'name': 'codecaine', 'age': 4}):
    print('valid data')
else:
    print('invalid data')
    print(v.errors)
Comment

PREVIOUS NEXT
Code Example
Python :: python function overloading 
Python :: get index of item in list 
Python :: easy python gui 
Python :: hiw ti count the number of a certain value in python 
Python :: change period to timestamp python 
Python :: python enable pyqt errors 
Python :: read excel by row and output to txt 
Python :: django query string route 
Python :: figure in matplotlib 
Python :: python find cells with na 
Python :: python 3 documentation 
Python :: pandas iter groups 
Python :: ljust rjust center python 
Python :: append string variable with integer python 
Python :: how to hello world in python 
Python :: update matplotlib params 
Python :: django table view sort filter 
Python :: get diagonals of 2d array 
Python :: python grab results from cursor.execute 
Python :: python how to write array into matlab file 
Python :: pdfs in django 
Python :: minio python make an object 
Python :: python switch item 
Python :: cv2.imwrite path 
Python :: python json nan 
Python :: enumerate word python 
Python :: python remove first element of list 
Python :: setup mongodb database with django 
Python :: fonction nombre premier python 
Python :: smallest possible number in python 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =