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

coerce and nullable #142

Closed
kseniyam opened this issue Sep 7, 2015 · 2 comments
Closed

coerce and nullable #142

kseniyam opened this issue Sep 7, 2015 · 2 comments

Comments

@kseniyam
Copy link

kseniyam commented Sep 7, 2015

The behaviour changed:

ID_SCHEME = {'_id' :{'type':'string', 'coerce':str, 'regex': r'[0-9abcdef]{24}', 'required':True, 'nullable':True}}
_id = {'_id':None}
v = Validator()
print(v.validate(_id, ID_SCHEME))
print(v.errors)

in version 9 this gives:
True
{}

and in version 10 the same gives:
False
{'_id': "value does not match regex '[0-9abcdef]{24}'"}

Is this intended change?

@funkyfuture
Copy link
Member

i don't think any of both behaviours was intended.

nonetheless i'd consider the recent as 'correct'. you can either extend your regex and dismiss the nullable-rule or implement #102 for a more clever coercion.

@funkyfuture
Copy link
Member

if you can omit the coerce-rule it should work as well. if i remember right, allowed None-values are not validated in-depth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants