How to use the fastjsonschema.draft06.CodeGeneratorDraft06 function in fastjsonschema

To help you get started, we’ve selected a few fastjsonschema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github horejsek / python-fastjsonschema / fastjsonschema / __init__.py View on Github external
def _get_code_generator_class(schema):
    # Schema in from draft-06 can be just the boolean value.
    if isinstance(schema, dict):
        schema_version = schema.get('$schema', '')
        if 'draft-04' in schema_version:
            return CodeGeneratorDraft04
        if 'draft-06' in schema_version:
            return CodeGeneratorDraft06
    return CodeGeneratorDraft07
github horejsek / python-fastjsonschema / fastjsonschema / draft07.py View on Github external
from .draft06 import CodeGeneratorDraft06


class CodeGeneratorDraft07(CodeGeneratorDraft06):
    FORMAT_REGEXS = dict(CodeGeneratorDraft06.FORMAT_REGEXS, **{
        'date': r'^(?P\d{4})-(?P\d{1,2})-(?P\d{1,2})\Z',
        'iri': r'^\w+:(\/?\/?)[^\s]+\Z',
        'iri-reference': r'^(\w+:(\/?\/?))?[^#\\\s]*(#[^\\\s]*)?\Z',
        'idn-email': r'^[^@]+@[^@]+\.[^@]+\Z',
        #'idn-hostname': r'',
        'relative-json-pointer': r'^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)\Z',
        #'regex': r'',
        'time': (
            r'^(?P\d{1,2}):(?P\d{1,2})'
            r'(?::(?P\d{1,2})(?:\.(?P\d{1,6}))?'
            r'([zZ]|[+-]\d\d:\d\d)?)?\Z'
        ),
    })

    def __init__(self, definition, resolver=None, formats={}):