File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ def __rich_repr__(self) -> rich.repr.Result: # pragma: no cover
110110
111111
112112class Validator (ABC ):
113- """ Base class for the validation of string values.
113+ ''' Base class for the validation of string values.
114114
115115 Commonly used in conjunction with the `Input` widget, which accepts a
116116 list of validators via its constructor. This validation framework can also be used to validate any 'stringly-typed'
@@ -120,13 +120,18 @@ class Validator(ABC):
120120
121121 Example:
122122 ```python
123+ def is_palindrome(value: str) -> bool:
124+ """Check has string has the same code points left to right, as right to left."""
125+ return value == value[::-1]
126+
123127 class Palindrome(Validator):
124128 def validate(self, value: str) -> ValidationResult:
125- def is_palindrome(value: str) -> bool:
126- return value == value[::-1]
127- return self.success() if is_palindrome(value) else self.failure("Not palindrome!")
129+ if is_palindrome(value):
130+ return self.success()
131+ else:
132+ return self.failure("Not a palindrome!")
128133 ```
129- """
134+ '''
130135
131136 def __init__ (self , failure_description : str | None = None ) -> None :
132137 self .failure_description = failure_description
You can’t perform that action at this time.
0 commit comments