Skip to content

Commit

Permalink
feat: add validation for mandatory fields
Browse files Browse the repository at this point in the history
(cherry picked from commit 4bc3d2e)
  • Loading branch information
GursheenK authored and mergify[bot] committed Oct 17, 2023
1 parent 301a698 commit 53b3783
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frappe/core/doctype/document_comparator/document_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json

import frappe
from frappe import _
from frappe.core.doctype.version.version import get_diff
from frappe.model.document import Document

Expand All @@ -22,8 +23,21 @@ class DocumentComparator(Document):
# end: auto-generated types
pass

def validate(self):
self.validate_doctype_name()
self.validate_document()

def validate_doctype_name(self):
if not self.doctype_name:
frappe.throw(_("{} field cannot be empty.".format(frappe.bold("Doctype"))))

def validate_document(self):
if not self.document:
frappe.throw(_("{} field cannot be empty.".format(frappe.bold("Document"))))

@frappe.whitelist()
def compare_document(self):
self.validate()
amended_document_names = frappe.db.get_list(
self.doctype_name,
filters={"name": ("like", "%" + self.document + "%")},
Expand Down

0 comments on commit 53b3783

Please sign in to comment.