Ejemplo n.º 1
0
def additional_validator():
    def raises_always(_):
        raise AdditionalValidatorError

    return get_validator(
        {},
        ValueError,
        additional_validation_strategy=raises_always,
    )
Ejemplo n.º 2
0
def additional_validator():
    def raises_always(_):
        raise AdditionalValidatorError

    return get_validator(
        {},
        ValueError,
        additional_validation_strategy=raises_always,
    )
Ejemplo n.º 3
0
        raise InvalidManifestError(
            'Invalid files regex at {0}: {1}'.format(
                hook_config['id'],
                hook_config['files'],
            )
        )


def additional_manifest_check(obj):
    for hook_config in obj:
        validate_languages(hook_config)
        validate_files(hook_config)


load_manifest = get_validator(
    MANIFEST_JSON_SCHEMA,
    InvalidManifestError,
    additional_manifest_check,
)


run = get_run_function(
    'Manifest filenames.',
    load_manifest,
    InvalidManifestError,
)


if __name__ == '__main__':
    exit(run())
Ejemplo n.º 4
0

def try_regex(repo, hook, value, field_name):
    if not is_regex_valid(value):
        raise InvalidConfigError(
            'Invalid {0} regex at {1}, {2}: {3}'.format(
                field_name, repo, hook, value,
            )
        )


def validate_config_extra(config):
    for repo in config:
        for hook in repo['hooks']:
            try_regex(repo, hook['id'], hook.get('files', ''), 'files')
            try_regex(repo, hook['id'], hook['exclude'], 'exclude')


load_config = get_validator(
    CONFIG_JSON_SCHEMA,
    InvalidConfigError,
    additional_validation_strategy=validate_config_extra,
)


run = get_run_function('Config filenames.', load_config, InvalidConfigError)


if __name__ == '__main__':
    exit(run())
Ejemplo n.º 5
0
}


def try_regex(repo, hook, value, field_name):
    if not is_regex_valid(value):
        raise InvalidConfigError('Invalid {0} regex at {1}, {2}: {3}'.format(
            field_name,
            repo,
            hook,
            value,
        ))


def validate_config_extra(config):
    for repo in config:
        for hook in repo['hooks']:
            try_regex(repo, hook['id'], hook.get('files', ''), 'files')
            try_regex(repo, hook['id'], hook['exclude'], 'exclude')


load_config = get_validator(
    CONFIG_JSON_SCHEMA,
    InvalidConfigError,
    additional_validation_strategy=validate_config_extra,
)

run = get_run_function('Config filenames.', load_config, InvalidConfigError)

if __name__ == '__main__':
    exit(run())
Ejemplo n.º 6
0
    if not is_regex_valid(hook_config.get('exclude', '')):
        raise InvalidManifestError(
            'Invalid exclude regex at {0}: {1}'.format(
                hook_config['id'], hook_config['exclude'],
            )
        )


def additional_manifest_check(obj):
    for hook_config in obj:
        validate_languages(hook_config)
        validate_files(hook_config)


load_manifest = get_validator(
    MANIFEST_JSON_SCHEMA,
    InvalidManifestError,
    additional_manifest_check,
)


run = get_run_function(
    'Manifest filenames.',
    load_manifest,
    InvalidManifestError,
)


if __name__ == '__main__':
    exit(run())
Ejemplo n.º 7
0
def array_validator():
    return get_validator({'type': 'array'}, ValueError)
Ejemplo n.º 8
0
def noop_validator():
    return get_validator({}, ValueError)
Ejemplo n.º 9
0
def array_validator():
    return get_validator({'type': 'array'}, ValueError)
Ejemplo n.º 10
0
def noop_validator():
    return get_validator({}, ValueError)