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
110
110
111
111
112
112
class Validator (ABC ):
113
- """ Base class for the validation of string values.
113
+ ''' Base class for the validation of string values.
114
114
115
115
Commonly used in conjunction with the `Input` widget, which accepts a
116
116
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):
120
120
121
121
Example:
122
122
```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
+
123
127
class Palindrome(Validator):
124
128
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!")
128
133
```
129
- """
134
+ '''
130
135
131
136
def __init__ (self , failure_description : str | None = None ) -> None :
132
137
self .failure_description = failure_description
You can’t perform that action at this time.
0 commit comments