andreymal · GitHub

It is uncomfortable for me. I have to write extra type checking.

This is OK (except #209, but it is not about that):

>>> v = Validator({'name': {'type': 'string', 'minlength': 6, 'regex': '[A-z]+'}})
>>> v.validate({'name': '©'})
False
>>> for field, value in v.errors.items():
...  print(field)
...  for error in value:
...   print(' -', error)
...
name
 - max length is 6
 - value does not match regex '[A-z]+'

But:

>>> v.validate({'name': 'abc'})
False
>>> for field, value in v.errors.items():
...  print(field)
...  for error in value:
...   print(' -', error)
...
name
 - m
 - a
 - x
 -
 - l
 - e
 - n
 - g
 - t
 - h
 -
 - i
 - s
 -
 - 6

WAT

I don't wish write if isinstance(value, str)!

Read the original on github.com ↗