How to use the yamale.validators.DefaultValidators function in yamale

To help you get started, we’ve selected a few yamale 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 23andMe / Yamale / yamale / syntax / parser.py View on Github external
def parse(validator_string, validators=None):
    validators = validators or val.DefaultValidators
    try:
        tree = ast.parse(validator_string, mode='eval')
        # evaluate with access to a limited global scope only
        return eval(compile(tree, '', 'eval'),
                    {'__builtins__': safe_builtins},
                    validators)
    except (SyntaxError, NameError, TypeError) as e:
        raise SyntaxError(
            'Invalid validation syntax in \'%s\', ' % validator_string +
            str(e)
        )
github 23andMe / Yamale / yamale / schema / schema.py View on Github external
def __init__(self, schema_dict, name='', validators=None, includes=None):
        self.validators = validators or val.DefaultValidators
        self.dict = schema_dict
        self.name = name
        self._schema = self._process_schema(DataPath(),
                                            schema_dict,
                                            self.validators)
        # if this schema is included it shares the includes with the top level
        # schema
        self.includes = {} if includes is None else includes
github 23andMe / Yamale / yamale / syntax / parser.py View on Github external
def parse(validator_string, validators=None):
    validators = validators or val.DefaultValidators
    try:
        tree = ast.parse(validator_string, mode='eval')
        # evaluate with access to a limited global scope only
        return eval(compile(tree, '', 'eval'),
                    {'__builtins__': safe_builtins},
                    validators)
    except (SyntaxError, NameError, TypeError) as e:
        raise SyntaxError(
            'Invalid schema expression: \'%s\'. ' % validator_string +
            str(e)
        )