Describe list with any number of elements, each matching given spec :param item_func: :py:class:`Spec` instance or a callable. Check out :py:meth:`Spec.check_list` documentation for more details. Note that in :py:meth:`Spec.check_list` description :py:class:`Spec` instance is repla
(self, item_func, msg_func=None)
| 486 | return self |
| 487 | |
| 488 | def list(self, item_func, msg_func=None): |
| 489 | '''Describe list with any number of elements, each matching given spec |
| 490 | |
| 491 | :param item_func: |
| 492 | :py:class:`Spec` instance or a callable. Check out |
| 493 | :py:meth:`Spec.check_list` documentation for more details. Note that |
| 494 | in :py:meth:`Spec.check_list` description :py:class:`Spec` instance |
| 495 | is replaced with its index in ``self.specs``. |
| 496 | :param function msg_func: |
| 497 | Function that should accept checked value and return message that |
| 498 | describes the problem with this value. Default value will emit just |
| 499 | “failed check”, which is rather indescriptive. |
| 500 | |
| 501 | :return: self. |
| 502 | ''' |
| 503 | self.type(list) |
| 504 | if isinstance(item_func, Spec): |
| 505 | self.specs.append(item_func) |
| 506 | item_func = len(self.specs) - 1 |
| 507 | self.checks.append(('check_list', item_func, msg_func or (lambda item: 'failed check'))) |
| 508 | return self |
| 509 | |
| 510 | def tuple(self, *specs): |
| 511 | '''Describe list with the given number of elements, each matching corresponding spec |