fix: stricter validation

This commit is contained in:
Sagar Vora 2021-11-11 12:29:49 +05:30
parent 9503e7788a
commit af41d9f8a5

View file

@ -407,10 +407,13 @@ def is_document_amended(doctype, docname):
return False
@frappe.whitelist()
def validate_link(doctype: str, docname):
def validate_link(doctype: str, docname: str):
if not isinstance(doctype, str):
frappe.throw(_("DocType must be a string"))
if not isinstance(docname, str):
frappe.throw(_("Document Name must be a string"))
if doctype != "DocType" and not (
frappe.has_permission(doctype, "select")
or frappe.has_permission(doctype, "read")
@ -420,5 +423,5 @@ def validate_link(doctype: str, docname):
.format(frappe.bold(doctype)),
frappe.PermissionError
)
return frappe.db.get_value(doctype, docname, cache=True)