Пример #1
0
def format_validator(swagger_spec, validator, format, instance, schema):
    """Skip the `format` validator when a Swagger parameter value is None.
    Otherwise it will fail with a "Failed validating u'format' in schema" failure instead
    of letting the downstream `required_validator` do its job.
    Also skip when a Swagger property value is None and the schema contains
    the extension field `x-nullable` set to True.
    In all other cases, delegate to the existing Draft4 `format` validator.

    """
    if (is_param_spec(swagger_spec, schema) or
            is_prop_nullable(swagger_spec, schema)) and instance is None:
        return

    for error in _validators.format(validator, format, instance, schema):
        yield error
Пример #2
0
def format_validator(swagger_spec, validator, format, instance, schema):
    """Skip the `format` validator when a Swagger parameter value is None.
    Otherwise it will fail with a "Failed validating u'format' in schema" failure instead
    of letting the downstream `required_validator` do its job.
    Also skip when a Swagger property value is None and the schema contains
    the extension field `x-nullable` set to True.
    In all other cases, delegate to the existing Draft4 `format` validator.

    """
    if (is_param_spec(swagger_spec, schema) or
            is_prop_nullable(swagger_spec, schema)) and instance is None:
        return

    for error in _validators.format(validator, format, instance, schema):
        yield error