Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error message if length of list is wrong #505

Closed
pravindahal opened this issue Aug 5, 2019 · 1 comment
Labels
bug
Milestone

Comments

@pravindahal
Copy link

@pravindahal pravindahal commented Aug 5, 2019

Used Cerberus version / latest commit: 1.3.1

  • I have the capacity to improve the docs when my problem is solved.

  • My question does not concern a practical use-case that I can't figure out
    to solve.

  • I have the capacity to submit a patch when a bug is identified.


Use-case abstract

Using list validator with incorrect number of items.


Bug report / Feature request

#!/usr/bin/env python2

from cerberus import Validator
import json

SCHEMA = {
    'test_list': {
        'type': 'list',
        'required': True,
        'items': [
            {
                'type': 'string',
            },
            {
                'type': 'string',
            }
        ]
    }
}

payload = {
    'test_list': [
        'test'
    ]
}

validator = Validator(SCHEMA)
validator.validate(payload)
print json.dumps(validator.errors)

Expected output:

{
	"test_list": ["length of list should be 2, it is 1"]
}

Actual output:

{
	"test_list": ["length of list should be [{'type': 'string'}, {'type': 'string'}], it is 2"]
}
@funkyfuture funkyfuture added the bug label Aug 5, 2019
@funkyfuture funkyfuture added this to the 1.3.2 milestone Aug 5, 2019
funkyfuture added a commit that referenced this issue Aug 5, 2019
@funkyfuture

This comment has been minimized.

Copy link
Member

@funkyfuture funkyfuture commented Aug 5, 2019

thanks for reporting!

@funkyfuture funkyfuture closed this Aug 5, 2019
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Aug 8, 2019
Fixes pyeve#505
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Aug 8, 2019
nicolaiarocci added a commit that referenced this issue Aug 9, 2019
* Adds support for Python 3.8

Fixes #505

* Adds CHANGES record for #505
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.