MCPcopy
hub / github.com/python-attrs/attrs / _MinLengthValidator

Class _MinLengthValidator

src/attr/validators.py:568–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566
567@attrs(repr=False, frozen=True, slots=True)
568class _MinLengthValidator:
569 min_length = attrib()
570
571 def __call__(self, inst, attr, value):
572 """
573 We use a callable class to be able to change the ``__repr__``.
574 """
575 if len(value) < self.min_length:
576 msg = f"Length of '{attr.name}' must be >= {self.min_length}: {len(value)}"
577 raise ValueError(msg)
578
579 def __repr__(self):
580 return f"<min_len validator for {self.min_length}>"
581
582
583def min_len(length):

Callers 1

min_lenFunction · 0.85

Calls 1

attribFunction · 0.85

Tested by

no test coverage detected