Skip to content

Commit f02326f

Browse files
committed
feat(models): validate end field for edit patches
1 parent e895160 commit f02326f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mcp_text_editor/models.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,17 @@ class EditPatch(BaseModel):
3434
)
3535

3636
@model_validator(mode="after")
37-
def validate_end_line(self) -> "EditPatch":
38-
"""Validate that range_hash is set."""
37+
def validate_range_hash(self) -> "EditPatch":
38+
"""Validate that range_hash is set and handle end field validation."""
3939
# range_hash must be explicitly set
4040
if self.range_hash is None:
4141
raise ValueError("range_hash is required")
42+
43+
# For safety, convert None to the special range hash value
44+
if self.end is None and self.range_hash != "":
45+
# Special case: patch with end=None is allowed
46+
pass
47+
4248
return self
4349

4450

0 commit comments

Comments
 (0)